javascript - Jquery dynamically change data value for ajax request -


i need function calculate every time last id of message inserted, way doesn't work, post initial number

 $("#conversazione").smartupdater({  url : "localhost/social/public/async/check-conversazione",  mintimeout: 2000,  type: 'post',  data: {      'id': id,     'last': $(".messaggioaltri:first").attr("data-number-message") }, datatype: 'json' }, function (data) {      if(data.aggiornamenti==1){          $.each(data.messaggi, function(indice, message){                         mess="<div class='singolomessaggio'> data-number-message="+message.number+">"                                 ....                                 "</div>";                          $(mess).hide();                         $(mess).css({'background-color': '#ff7519'});                         $('#messaggiconversazione').prepend(mess);                         $(mess).fadein(1000);                         $(mess).removeattr("style");                                               });       }else{         //nothing     }  } ); 

i tried use function instead, like:

$("#conversazione").smartupdater({  url : "localhost/social/public/async/check-conversazione",  mintimeout: 2000,  type: 'post',  data: {     'id': id,    'last': getlast()  },....etc...  function getlast(){  return $(".messaggioaltri:first").attr("data-numero-messaggio"); } 

but have same error, fierbug see send initial numbers...it seems soo simple cannot figure out what's wrong...what suggest do?

try json.stringify

$("#conversazione").smartupdater({  url : "localhost/social/public/async/check-conversazione",  mintimeout: 2000,  type: 'post',  data: json.stringify({'id':id,'last': getlast()}), ....etc... }); 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -