I have a javascript
file pet.js
. I want to pass a value of variable in test.php
. But i can't.
my pet.js
is like
$('#pmWorkOrderDetailsPage').live('pageshow', function(event) {
var id = getUrlVars()["id"];
$.get("test.php", { test1: id } );
$.getJSON('pmworkorderdetails.php?id='+id, displaypmWODetails);
});
function displaypmWODetails(data) {
..............code..........
}
My test.php
is like
<?php
$ms = $_GET["test1"];
echo $ms;
?>
But it is not working. I tried with Ajax
and post
method.
It will be best if I can store the variable value on the session in test.php.
Thanks in advance for any help.
echo
statement in test.php, but you're not using a callback to handle that data in pet.js. What exactly do you want to do with the output of test.php?echo json_encode($ms);
. Also, you may need to add a json header