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
Post a Comment