dlebowski Posted October 9, 2012 Share Posted October 9, 2012 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'); Quote Link to comment https://forums.phpfreaks.com/topic/269265-json-and-assigning-results-to-javascript-variable/ Share on other sites More sharing options...
trq Posted October 9, 2012 Share Posted October 9, 2012 The assignment your using works as expected. Where are you trying to then use theyear ? Quote Link to comment https://forums.phpfreaks.com/topic/269265-json-and-assigning-results-to-javascript-variable/#findComment-1384062 Share on other sites More sharing options...
dlebowski Posted October 9, 2012 Author Share Posted October 9, 2012 (edited) 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 October 9, 2012 by dlebowski Quote Link to comment https://forums.phpfreaks.com/topic/269265-json-and-assigning-results-to-javascript-variable/#findComment-1384065 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.