How to send data to remote server using Javascript -


i need send data remote server using javascript. how do this?

background info: there's webpage extract information using js, , need send server processing. response not neccesary. data xml, i've urlencode'd.

how 1 this?

edit

the server i'm requesting data not same receives data. clarify.

one of common ways ajax. here's how perform ajax post request using jquery:

<script type="text/javascript">   $.post('/remote-url', {xml: yourxmlstring }); </script> 

on server side process other post request. if you're using php it's $xml = $_post['xml'];

the biggest limitation of ajax you're allowed make requests same domain document has been loaded (aka cross-domain policy). there various ways overcome limitation, 1 of easiest 1 jsonp.


upd. cross-domain requests extremely simple (though not universal) solution be:

(new image).src = 'http://example.com/save-xml?xml=' + escape(yourxmlstring) 

this issue request (which cannot exceed 2kb in internet explorer). if absolutely need post request or support larger request bodies can either use intermediate server-side script on domain or can post dynamically created html form iframe.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -