|
地板
楼主 |
发表于 2017-5-11 14:41:29
|
只看该作者
本帖最后由 firemail 于 2017-5-12 12:20 编辑
网络请求- //var oReq = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].
- // createInstance(Ci.nsISupports);
- /////////get/////
- var oReq = new XMLHttpRequest();
- oReq.open("GET", "http://127.0.0.1:8080/zmkj/f/zm/api/putData");
- oReq.addEventListener("error", function(event) { alert(event); } ,false);
- oReq.onload = function(event) {
- alert(event)
- // var retbuffer = oReq.response;// not responseText
- // alert(retbuffer)
- var buffer = oReq.responseText;
- alert(buffer)
- }
- oReq.send();
复制代码 post方法
Submitting forms and uploading files
Instances of XMLHttpRequest can be used to submit forms in two ways:
using only AJAX
using the FormData API
https://developer.mozilla.org/en ... sing_XMLHttpRequest
https://developer.mozilla.org/en ... ng_FormData_Objects- var formData = new FormData();
- formData.append("username", "testUser");
- var request = new XMLHttpRequest();
- request.open("POST", "http://127.0.0.1:8080/zm/f/zm/api/postData");
- request.onload = function(oEvent) {
- alert(request.status + request.responseText)
- };
- request.send(formData);
复制代码 |
|