function start(){
$('#detailsPage').live('pageshow', function(event) {
var user_name = getUrlVars()["user_name"];
//var user_name = "studentB";
$.getJSON('http://mydomain.com/getStudent.php?user_name='+user_name+'&jsoncallback=?', displayStudent);
});
}
above is the js and below is the php
<?php
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
header("Content-type: application/json");
include('mysqlConfig.php');
$user_name = $_GET["user_name"];
$sql="SELECT * FROM tbl_user WHERE user_name='$user_name'";
$result=mysql_query($sql);
$rows = array();
//retrieve and print every record
while($r = mysql_fetch_assoc($result)){
// $rows[] = $r; has the same effect, without the superfluous data attribute
$rows[] = array('data' => $r);
}
// now all the rows have been fetched, it can be encoded
//echo json_encode($rows);
$data = json_encode($rows);
echo $_GET['jsoncallback'] . '(' . $data . ');';
?>
i wondering if this method work or not? in my app, nth is display. i am not sure if the jsoncallback value is wrongly implemented. your opinions will be a great help. thanks