怎样从网上下载一张图片,并保存到本地呀???
local xmlhttp = cc.XMLHttpRequest:new()
xmlhttp.response = cc.XMLHTTPREQUEST_RESPONSE_STRING
xmlhttp:open(“GET”,“http://edu.dogame.com.cn/manage/uploadfile/201408181408344679.jpg”)
local function responseback()
if xmlhttp.readyState == 4 and (xmlhttp.status >= 200 and xmlhttp.status < 207) then
print(xmlhttp.response)
if xmlhttp.response ~= nil then
print(“已经获取到数据了”)
print(xmlhttp.response)
end
end
end
xmlhttp:registerScriptHandler(responseback)
xmlhttp:send()
为什么我写的这个代码,返回的数据一直是0呀????
求大神给我指导指导呀