Send values to back Javascript with json and .post

All, I have the following code:

$.post("save.php", {rate: value, vendor: vendor_id}, function(results)
}, "json");

I get the data and do some updates to the database. When I'm done I'd like to pass back $var1, $var2. Then parse those values and put them into a div. How can I send these values back so I can access them in something like:


Then I can put that value of var1 into a div. Thanks for the help!


You would create an associative array holding your data, turn it into JSON and return it:

$data = array('var_one' => $var1, 'var_two' => $var2);
$jsonData = json_encode($data);
echo $jsonData;

You can read about manipulating elements with jQuery to learn about inputting the data into your HTML.

Need Your Help

When does ThreadLocalStorage get cleaned

c# thread-local

if i put things in c# TLS when does it get cleaned, or is it my job to clean it?

Generate certificate on windows azure web or worker role using makecert.exe

wcf azure certificate makecert

We are planning to create and install self-signed certificates on azure web roles.