lua XMLHttpRequest下载

来源:互联网 发布:大纲软件 编辑:程序博客网 时间:2024/05/22 14:35
local function onNodeEvent(event)        if "exit" == event then            cc.Director:getInstance():getScheduler():unscheduleScriptEntry(self.schedulerID)        elseif "enter" == event then            print("-->test began")            local xhr = cc.XMLHttpRequest:new()            xhr.responseType = cc.XMLHTTPREQUEST_RESPONSE_STRING            xhr:open("POST","http://httpbin.org/post")             local function onReadyStateChange()                print("status:"..xhr.statusText.."response:"..xhr.response)            end            xhr:registerScriptHandler(onReadyStateChange)            xhr:send()            print("-->test end")        end    end

输出如下:

[LUA-print] -->test began[LUA-print] -->test end[LUA-print] status:200 OKresponse:{  "args": {},   "data": "",   "files": {},   "form": {},   "headers": {    "Accept": "*/*",     "Content-Length": "0",     "Content-Type": "application/x-www-form-urlencoded",     "Host": "httpbin.org"  },   "json": null,   "origin": "222.128.185.92",   "url": "http://httpbin.org/post"}



0 0