Jump to content

AJAX Post Issue?


mat-tastic

Recommended Posts

Hey Guys,

 

I am having problems with AJAX post method. I have the GET Method working, post is causing a problem:

 

This is the function: (ignore the alerts, I was trying to debug)

 

function confirmid()
{ 

xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
var url="charter.php"
url=url+"?resend"
// url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged 
var idvalue=encodeURIComponent(document.getElementById("charterid").value)
var emailvalue=encodeURIComponent(document.getElementById("email").value)
var parameters="charterid="+idvalue+"&email="+emailvalue
alert (parameters)

xmlHttp.open("POST","charter.php?resend",true)
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.send(parameters)
}

 

stateChanged (which I know works fine)

 

function stateChanged() 
{ 
alert ("state is changed")
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{ 
document.getElementById("displayresult").innerHTML=xmlHttp.responseText 
} 
else
{
var loadingText = '<img src="loading.gif" border="0" alt="running" />';
document.getElementById("displayresult").innerHTML = loadingText; // still working
}
}

 

For some reason the alert isn't showing up in stateChanged when my function calls it.

 

The parameters all work fine. They show up. The request doesn't seem to be going through.

 

Any ideas?

 

If you need any more info, I shall give.

 

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.