开发者

Sending user agent and postdata with sync request?

I've got the following synchronous request...

    var xhr = new XMLHttpRequest();
    xhr.open("GET",uri,false);
    xhr.send(null);

I've read http://www.w3.org/TR/XMLHttpRequest/#the-open-method and it appears that this doesn't al开发者_开发问答low for extra parameters. Basically I'd like to send other data such as postdata and useragent how would I do this using AJAX?


 var strResult;
    var xhr = new XMLHttpRequest();
    xhr.open("POST",uri,false);
    xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    xhr.send("id=1&user="+txtUser.value+"&password="+txtPassword.value);
    strResult=xhr.responseText;

i'm not 100% sure, but i think you can pass .send() extra parameters.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜