Jump to content

Json And Assigning Results To Javascript Variable


dlebowski

Recommended Posts

Any help with this would be greatly appreciated! When I use "response[0].Data" to assign a value to innterhtml, it works great. If I try to assign the value to a javascript variable (theyear = response[0].Data1;), it doesn't assign it. How do I do this? Thank you for your help!

 

Here is the value:

 

[{"Data":"3025.00","Data1":5}]

 


var theyear;

function runPost(thedate, thelotnumber, myid)
{

$jq.post("current.php?q="+moreurl,
 {
 data: thedate, data2: thelotnumber, data4: myid
 },
 function(response, status)
 {
								 document.getElementById("thecurrent").innerHTML = response[0].Data;


 theyear = response[0].Data1;

 },
 'json');

theyear is just a javascript variable that will be used in a function. And when the results are returned, the variable doesn't change. I don't get any errors or anything in firebug. The variable just doesn't change at all.

 

Is that what you were asking me. Thank you for helping me out.

 

Ryan

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.