javascript - Passing values between functions and jquery -


I'm assuming the difficulty jib in jQuery, so most of jQuery is done in an external script as, and I am not sure that when I am in functions and not in functions, it is difficult to say that when global wars are set and not set.

This one especially bothers me, and I'm completely stumped, logically I should work on it, but at some point it seems something capping, and I think those values I'm ignoring the ones I am trying to store.

I have concluded this, because the error I am getting is inside the second getJSON call, I'm getting 'val' undefined problem, but javascript console is not showing any javascript errors , Just when I log on to the console and print the object in a warning.

Just need a new eyes, it seems that this is probably something simple, but I see the code for so long that I do not know this.

> Any help is greatly appreciated.

  var post_ids = new array (); Var i = 0; Var Val; $ .getJSON ("/ client-ajax / last-ten posts.php", function (data) {$ .Every (data, function (k, val) {post_ids.push (val.id);})}} ; $ .getJSON ("? / Client-ajax / last-ten post.php id =" + post_ids [0], function (val) {warning (val.title + ""); $ ("# postContainer") Empty (); $ ("# postContainer") attached ("& lt; p class = 'title' & gt;" + val.title + " & lt; div class = ' Post by icon after & lt; / div> gt; pre & gt; "+ val.content +" & lt; / pre & gt; & lt; p class = 'footnote' & gt; On "+ val.firstname +" "+ val.surname +", the time datetime = '2014-06-10' & gt; 08: 52 & lt; / time & gt; GMT +00 & lt; Time & gt; 2014-10-06 & lt; / time & gt; & lt; / p & gt; ");});  

Update:

I have edited a bit of code in response to code @ N0ir, but no success. The methodology ensures that action is taken after the completion of the asynchronous process, but although this is the case, the val is still undefined. The code I have tried is below for examination and dissemination.

  $ GetJSON ("/ client-ajax / last-ten posts.php", function (data) {$ .Every (data, function (k, val) {post_ids.push (val.id);});} (done Function () {$ .getJSON ("/ client-ajax / last-ten posts.php post.? -id =" + post_ids [0], function (val) {warning (val.title + ""); $ ( "# PostContainer") below (); .. $ ("# postContainer") attaching ("& lt; p class = 'title' & gt;" + val.title + "& lt; / p & gt; & lt ; Div class = 'icon after' gt; & lt; / div & gt; & lt; pre & gt; "+ val.content +" & lt; / pre & gt; & lt; p class = 'footnote '& Gt; Time datetime =' 2014-06-10 '& gt; 08 "+ val.firstname +" at & lt; "+ val.surname +" Posted by: 52 & lt; / s Y & gt; & lt; time & gt; 10-06-2014 & lt; / time & gt; & lt; / p & gt; ";}};}) at GMT + 00;  

Update - Network return on phone for JSON:

  get http: // ************** ** com / client Get -ajax / last-ten-posts.php [get HTTP / 1.1 200 OK 154 mms] http: // ********************************************************** Revised 152ms] Not Received HTTP: http: // ******************************************************************************************** *** com / img / about-repeat.jpg [http / 1.1304 not modified 147ms] http: // ** ************************************** Jpg [http / 1.1304 not modified 146ms] http:. // ************ **** com / img / portfolio.jpg [http / 1.1304 not modified 210ms] http: //******img/contact Jpg [HTTP / 1.1304 Modified 20 9ms] Get HTTP: // ****************************************************************************** **************************************************************************************************** ******** 200 OK 207ms]  

Want to do something:

  var post_ids = new array (); Var i = 0; Var Val; $ .getJSON ("/ client-ajax / last-ten posts.php", function (data) {$ .Every (data, function (k, val) {post_ids.push (val.id);}); $ GetJSON ("? / Client-ajax / last-ten post.php" id = "+ post_ids [0], function (results) {warning (result.title +" "); $ (" # postContainer "). );. $ ("# PostContainer") attached ("& lt; p class = 'title' & gt;" + result.title + "& lt; / p & gt; & lt; div class = 'icon after 'And gt; 
"+ result.content +"

time; & lt; & lt; & lt; / pre & gt; Out of "+ result.firstname +" "+ result.surname +" was published datetime = '2014-06-10' & gt; 08: 52 & lt; / time & Gt; GMT +00 & lt; time & gt; 2014-10-06 & lt; / time & gt; & lt; / p & gt; ");});});

so that the first time after the getJSON call ends.


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -