Possible Duplicate:
Using jQuery to compare two arrays
I have to send the form data via ajax to server on say every 30 second. Now I want it to be checked at client end and ajax been hit only in case there is any change in form. I am using:
var lastData = "";
function saveFormInDB(){
var $form = $("#fb_divBl0ck1").closest('form');
var isSame = false;
data = $form.serializeArray();
if(lastData == ""){
lastData = data;
}else{
if(lastData == data){
isSame = true;
}
lastData = data;
}
if(!isSame){
jqxhr = $.post("/SPSKMEForm/FormSaveServlet", data)
.success(function() {
if(jqxhr.responseText != ""){
alert(jqxhr.responseText);
alert($("#fixedFooter"));
alert($("#fixedFooter").html());
$("#fixedFooter").text(jqxhr.responseText).css("display", "");
$("#fixedFooter").fadeOut("slow");
}
});
}
}
but isSame
is coming to be false always.