views:

38

answers:

2

I have a jquery function that hooks a javascript function when my form table is created, only it seems to respond too quickly.

My function being called is:

    function ValidateForm(CQID)
    {

 var dt=document.newDate.txtDate;

 if (isDate(dt.value)==false){
  dt.focus();
  return false;
 }

    populateDateTable(dt.value, CQID); 
    }

This function works only when I add an empty alert(''); at the end, otherwise it falls through and does not submit the ajax request.

Within my populateDateTable() function I included the proper ready state conditionals.

    xmlhttp.onreadystatechange=function()
  {
    if (xmlhttp.readyState==4 && xmlhttp.status==200)
      {
      document.getElementById("BoxCarCapacityDates").innerHTML= xmlhttp.responseText;
      }
  }

Is there anything I didn't include properly?

A: 

Can you post more code? like from where u call validateform() and when the ajax is called.. Its always good to call functions in an order.. If u want the ajax to be called only after some function is executed, just call the ajax at the end of function..

For example..

function your_normal_function()
{
 //function code;

 ajax_fun();
}


function ajax_fun()
{
  // ajax function code here

}


something.onmouseout = your_normal_function;
kvijayhari
A: 

Is the AJAX code actually hitting your web server? There would be a hit in the access log showing that it did, if so. You might be better off using something like jquery or mootools instead of rolling your own AJAX-handling code. They hide all of the picky little differences between browsers and simplify the whole AJAX experience, plus are able to give better feedback in case an error occurs.

Marc B