Jump to content

[SOLVED] POST data with Asynchronous call


leesiulung

Recommended Posts

Basically, I'm writing my own proxy for AJAX using the XMLHttpRequest object. My problem is with an asynchronous call as follows:

 

   if(XMLHttpRequestObject.overrideMimeType) XMLHttpRequestObject.overrideMimeType('text/xml');

   url = 'proxy.php?proxy_url=' + escape('http://www.google.com');  
   XMLHttpRequestObject.open('POST', url, true);
   XMLHttpRequestObject.setRequestHeader('Content-Type', 'text/xml');
   XMLHttpRequestObject.setRequestHeader('SOAPAction', '""');
   XMLHttpRequestObject.onreadystatechange = getResults;

   XMLHttpRequestObject.send(....)

 

The problem I have is that the proxy.php page is not able to retrieve the information being sent in the $_POST array. Where should this data be? Since the XMLHttpRequestObject does not name the data like a regular POST from a form with fields....

 

How can I retrieve this data?

 

Any help would be much appreciated as I spent many days on this problem.

 

Note, this problem stem from an earlier post that asked a different question. Basically I had to create my own proxy script since the original ones I used did not supply the correct information to the server in the header etc... I can't seem to edit my posts. Is there an edit button I missed?

 

Other thread here

 

edit: found the edit button.

Link to comment
Share on other sites

Sorry, that url just happens to be there as I was typing it in. I will try to be clearer next time.

 

The correct url is 'http://services.xmethods.net/soap'. I'm trying to send a soap envelope, but with the content-type set at text/xml the proxy.php page does not receive the POSTED data sent by the XMLHttpRequestObject.

 

I will edit the code in original post to reflect this.

 

edit: actually I can't edit the original post as there is no such option on the page.

Link to comment
Share on other sites

You don't need to post as text/xml though, as I don't believe it's required.  However, if it is in fact needed, what you should do is post it as application/x-www-form-urlencoded to the PHP script, then have a POSTBODY attribute such as: contenttype=text/xml&therestofyourdata, then when the proxy connects to the SOAP server, it sends it as text/xml.  But again, at least in Apache/PHP as far as I know, unless the content-type is application/x-www-form-urlencoded, data will not be picked up.

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.