How can I create web service functionality via html and JavaScript
I 开发者_如何转开发want write a page that returns nothing but reads the parameters posted to it and manipulate them (via JavaScript) before similarly posting to third party's page. Anything returned from the third party will be dropped on the floor. Basically, I'm looking to create a proxy. My 'middle' page will need to run JavaScript. The end page will post to the middle page but not leave the page or report the status of the post.
You'll need to pass the values to your proxy using the GET
form method and use window.location.search
to get the values (this will only work with simple values, not file uploads).
var qsParm = new Array();
function qs() {
var query = window.location.search.substring(1);
var parms = query.split('&');
for (var i=0; i<parms.length; i++) {
var pos = parms[i].indexOf('=');
if (pos > 0) {
var key = parms[i].substring(0,pos);
var val = parms[i].substring(pos+1);
qsParm[key] = val;
}
}
}
javascript.about.com article on query passing
To resend you'll need to create and populate a form and them call the submit()
method on the form element.
精彩评论