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