我在嘗試通過URLRequestMethod.POST;
AS3中的URL編碼變量?
Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs.
傳遞變量時,下面的錯誤是否有字符串URL編碼的方法?
我在嘗試通過URLRequestMethod.POST;
AS3中的URL編碼變量?
Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs.
傳遞變量時,下面的錯誤是否有字符串URL編碼的方法?
解決這個問題是: 你必須設置URLLoaderDataFormat到URLLoaderDataFormat.TEXT不URLLoaderDataFormat.VARIABLES.
因爲VARIABLES
是指不同類型的數據,在URLVariables
不是多個項目。
作爲ActionScript 3的頂級函數,存在用於URL編碼/解碼的escape()和unescape()。
該錯誤消息通常是由將非有效的查詢字符串傳遞給URLVariables對象造成的。但在大多數情況下,您不需要傳遞查詢字符串。您可以將對添加到對象中作爲常規屬性,並讓它執行編碼和轉義(這是此類所要執行的操作)。
var vars:URLVariables = new URLVariables();
vars.param1 = "Text to be escaped. Works for non ascii: ñ";
vars.param2 = "http://www.google.com/?q=something&test=1234";
trace(vars.toString());
當然,跟蹤不是必需的,它只是讓你可以看到編碼工作。
這有助於解決我遇到的另一個問題。謝謝。 – Mattias 2011-12-14 09:35:28
我碰到過這個問題很多次,通常是我錯過的myLoader.dataFormat = URLLoaderDataFormat.VARIABLES
這一行。嘗試,如果你把它刪除這一行:
request.method = URLRequestMethod.POST
,最終確保你是通過變量theStatus=okay
那麼應該做的伎倆接收響應。
如果你想編碼分隔符,'encodeURIComponent'和'decodeURIComponent'也是有用的。 – 2015-04-19 18:35:36