how to get a return value from ajax and php
ive set up a php file, called by ajax, to interact with my database. so far i have successfully used json to get the data back from the sql requests. now i am returning my own values from the php file, and trying to get the value back into my javascript. but they are returning as empty. this is how i am doing it:
// in th开发者_运维问答e php file, gets data and database, and returns a number through echo
$result = 2;
echo $return;
//the javascript which calls the ajax and gets the value
var temp = ajaxdb(args);
showError(temp);
show error displays the variable in a div.
i know that my functions are working properly, as they work well when i return a json string, and parse it into an array. but how can i get my custom values from the php?
echo json_encode($return);
精彩评论