I have two functions that work fine individually, but when used together, create the other function not to work for some reason.. :'(
My first function submits a form using ajax:
$(function() {
$("#saveList").click(function() {
var listname = $("input#listname").val();
if (listname == "")
{
$('#listnameError').fadeIn("slow");
setTimeout("$('#listnameError').fadeOut('slow')", "1200");
return false;
}
$('#loading').fadeIn("slow");
var hiddenid = $("input#hidden_id").val();
var todo1 = $("input#todo1").val();
var todo2 = $("input#todo2").val();
var todo3 = $("input#todo3").val();
var todo4 = $("input#todo4").val();
var todo5 = $("input#todo5").val();
var todo6 = $("input#todo6").val();
var todo7 = $("input#todo7").val();
var todo8 = $("input#todo8").val();
var todo9 = $("input#todo9").val();
var todo10 = $("input#todo10").val();
var dataString = 'listname='+ listname + '&hidden_id=' + hiddenid + '&todo1=' + todo1 + '&todo2=' + todo2 + '&todo3=' + todo3 + '&todo4=' + todo4 + '&todo5=' + todo5 + '&todo6=' + todo6 + '&todo7=' + todo7 + '&todo8=' + todo8 + '&todo9=' + todo9 + '&todo10=' + todo10;
$.ajax({
type: "POST",
url: "save.php",
data: dataString,
success: function()
{
$('#loading').fadeOut("slow");
$('#sucessAlert').fadeIn("slow");
setTimeout("$('#sucessAlert').fadeOut('slow')", "2200");
setTimeout('disableForm(false)', '1300');
}
});
return false;
});
});
This function saves users lists, and works perfectly in all browsers; However, once I add my other function that updates a portion of the page, it creates a very strange result, making them both work fine at first, then after saving a few lists, the first function stops working completely...
Here is the second function which updates part of the page(and is causing the first function to stop working):
function currentLists()
{
var xmlhttp;
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("allLists").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","currentlists.php?t=" + Math.random(),true);
xmlhttp.send();
}
I'm guessing that something about the http requests on the second function somehow interferes with the first ajax function, and I need them to work together
thanks in advance for your help!