Hamed mayahian
Hamed mayahian

Reputation: 2343

how to send data in another page with html and ajax

i'm starting delevope android application with phonegap as you may know i can't use php file in front-end of my app, so i have a list that create dynamic when user click on the each link go to the singers_category.html and base of the the $genre_id i want load group of singers on singers_category.html; i'm try using QueryString but i'm think i can't using QueryString in html page; so this is my code of php handler: (i'm using switch case to using multiple handler in one page)

<?php
include('db_inc.php');
$functionId=$_GET['functionId'];
echo "$functionId <br>";
switch($functionId){
    case "":
    $singer_id =$_POST['last_items'];
    $result = $connection->query("SELECT * from genre")or die($connection->error);
        while($row = $result->fetch_object()){
            $genre_name = $row->genre_name;
            $genre_id = $row->genre_id;
            echo "<li><a href='singers_category.html?$genre_id >$genre_name</li>";
            }
            $connection->close;
            break;
    }


?>

my question is:how to access specific $genre_id with ajax and html and one php handler in singers_category.html

Upvotes: 0

Views: 683

Answers (3)

Hamed mayahian
Hamed mayahian

Reputation: 2343

for this issue we can use this script: http://jquery-howto.blogspot.com/2009/09/get-url-parameters-values-with-jquery.html

Upvotes: 0

Dean.DePue
Dean.DePue

Reputation: 1013

You would capture the item to be returned in JS like this:

function CloseWindow() {
        var hidchg = document.getElementById('<%=hidItemsChanged.ClientID %>');
        window.opener.TransDataChange(hidchg.value);
        window.open('', '_self', ''); window.close();
        return false;
    }

and capture in sending page like this:

function TransDataChange(changeMade) {
if (changeMade == "true") {
    //..do something    }

}

Upvotes: 1

Purus
Purus

Reputation: 5799

The format that you use is

 echo "<li><a href='singers_category.html?genre=" . $genre_id . "'>" . $genre_name . "</a></li>";

After this, in your code you can read that by:

$_GET['genre']

Upvotes: 0

Related Questions