I have 2 files, main.html and search.php.
Within the main.html page, there is this piece of code :
$("#results").load("search.php",queryString,function(response,status,xhr){
... some code here
})
Within the search.phppage, there is this piece of code :
$image_id=mysql_insert_id() // getting the last ID of the last query - works perfectly
What I want to do is to echo this variable to the main.html file and store it within a JS variable called im_id that I can call through the main.html page.
I tried to do this
echo "<script type=\"text/javascript\">$im_id=".mysql_insert_id()."</script>";
but it doesn't work at all.
I found a workaround which is to store the content within a textbox like this
echo "<script type=\"text/javascript\">$(\"#textbox\").val(".$image_id.")</script>";
and then in the JScript, use
$im_id=$("#textbox").val();
and many other methods using an "intermediary" but isn't there a straight way to set the variables directly ?
Any help would be appreciated.