1
我試圖用數據發送POST請求到另一個域名與該代碼的編譯:AS3的URLRequest POST只工作當HTML包裝
_snapshot_id = 1369022400;
var urlRequest:URLRequest = new URLRequest("https://fuzzykittens/radar");
urlRequest.method = URLRequestMethod.POST;
urlRequest.contentType = "application/x-www-form-urlencoded";
//set variables for post
var postVars:URLVariables = new URLVariables();
postVars.snapshot = String(_snapshot_id);
urlRequest.data = postVars;
//initialize weather proccess request
weatherProcRequest = new URLLoader(urlRequest);
weatherProcRequest.addEventListener(Event.COMPLETE,
weatherProcRequest_CompleteHandler);
weatherProcRequest.addEventListener(IOErrorEvent.IO_ERROR,
weatherProcRequest_ErrorHandler);
weatherProcRequest.addEventListener(SecurityErrorEvent.SECURITY_ERROR,
weatherProcRequest_ErrorHandler);
weatherProcRequest.load(urlRequest);
當我設置Flex編譯器使用的HTML包裝,該請求起作用。當我不使用包裝器時,請求會拋出一個io錯誤#2032。我認爲這不是發送快照ID,但我不知道爲什麼。
有什麼明顯的原因,爲什麼在html包裝器中調試時請求會發送數據,而在html包裝器外面調試時未能這樣做?
fuzzykittens與
<allow-access-from domain="*" secure="false"/>
更具體的關於您的環境可能會有所幫助(您是將AIR用於桌面應用程序還是移動應用程序,還是您正在嘗試單獨執行SWF,如果是這樣,爲什麼?)根據上下文有不同的安全限制的SWF執行。 – shaunhusain
我正在運行SWF。這樣做的決定不是我自己的,所以我不知道爲什麼。當我使用HTML包裝器時,它在Firefox中打開。謝謝,這是我的第一個堆棧溢出問題。 – user2437252
這可能是當您使用URLRequestMethod.POST而沒有包裝時,請使用URLRequestMethod.GET進行測試。您還可以監聽URLLoader上的HTTPStatusEvent.HTTP_STATUS和HTTPStatusEvent.HTTP_RESPONSE_STATUS以查看返回的狀態 – michaPau