Jump to content

Update a table using AJAX


aniesh82

Recommended Posts

 

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

 

 

Link to comment
Share on other sites

I don't see that your doing anything at all with the AJAX returned responseText.

 

I also use AJAX as an object ....... var testObj = new AJAXFunction()

 

Here you appear to be using a function, creating the object inside the function and then doin not a lot with it, there's no check after the send only b4 so I'm assuming that it returns nothing. You don't use contact_id at all even though it's set at the beginning.

 

Just a few suggestions, hope they help

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.