NYCPHP Meetup

NYPHP.org

[nycphp-talk] Update a table using AJAX

Aniesh joseph anieshjoseph at gmail.com
Wed Apr 25 01:10:43 EDT 2007


Hello

I have a html form with action to paypal's site. When submitting the page, I
need to update the table with the form values( USING AJAX) .

To do this I write the following code.

<script>

/* Call this function on the onClick of the submit button */

function check_form_values()
{
    /* Inside this function I check wether the USER enters the details */

    ajaxFunction();

    /*  IT WORKS PERFECTLY IF WE UNCOMMENT THIS ALERT PAGE  */
}



function ajaxFunction()
{

append_url =
'contact_info.php?contact_id='+document.form1.user_id.value+'&contact_name='+document.form1.contact_name.value+'&position='+document.form1.position.value+'&email='+document.form1.email.value+'&telephone='+document.form1.telephone.value+'&mobile='+document.form1.mobile.value+'&company='+document.form1.company.value+'&address='+document.form1.address.value;

  var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
    xmlHttp.onreadystatechange=function()
    {
          if(xmlHttp.readyState==4)
           {
        //response_txt         =    xmlHttp.responseText;

       }
    }
    xmlHttp.open("GET",append_url,true);
    xmlHttp.send(null);

  }

</script>

I am trying to update the table using the contact_id field, I did not return
any values from AJAX action page.

But this code did not work properly.


If I uncomment the alert inside the function "check_form_values()", then
updation will work perfectly.


Can someone help me to fix this problem ?


Regards
Aniesh Joseph
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20070425/6f7d15d5/attachment.html>


More information about the talk mailing list