Jump to content

Ajax calling PHP script


McPete.

Recommended Posts

Hi,

 

I'm trying to create an AJAX script which reads a text string from a php script. I've managed to do this and it works fine. Problem is, when the php script is ran, it's supposed to add a record to a database.

 

If I run the script through a browser it does this, but when called from the ajax script it doesn't. I've managed to get this to work before when calling xml, but as I'm doing it a different way as it's calling text I'm a bit stuck!

 

I've attached the code I'm using at the moment. If anyone has any idea's or suggestions I'd be eternally grateful :)

 

Thanks,

 

Pete.

 

	request = false;
if (window.XMLHttpRequest) {
   		request=new XMLHttpRequest();

} else if (window.ActiveXObject) {
    		request= new ActiveXObject("Microsoft.XMLHTTP");
	} else alert("your browser does not support Ajax");

  if(request!=false) {
request.onreadystatechange=Resp;
        request.open("GET",url,true);
        request.send(null);
}
    }	
}

function Resp() {
var Text;
if (request.readyState==4) {
    		if(request.status==200) {
                  respon=request.responseText;
		showBasket(respon);
	}
  	}
}

Link to comment
https://forums.phpfreaks.com/topic/157845-ajax-calling-php-script/
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.