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');

Link to comment
Share on other sites

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

Edited by dlebowski
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.