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
https://forums.phpfreaks.com/topic/144736-ajax-post-issue/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.