iT邦幫忙

5

ActionScript使用navigateToURL時,無法使用POST的解決方法

使用navigateToURL時,會餵進一個URLRequest的實體物件,而這個URLRequest可以透過URLRequest.method來指定傳送時使用POST或GET。

今天發生一個怪事,明明已經指定 request.method = URLRequestMethod.POST這個常數給他了,但是實際發送時,還是使用GET。
Google了半天,也試了一些怪招,怎麼樣都是用GET,真的沒辦法了,回Adobe官網查一下URLRequest究竟怎麼處理method。

最後終於看到了一行:

Note: If running in Flash Player and the referenced form has no body, Flash Player automatically uses a GET operation even if the method is set to URLRequestMethod.POST.

來源:http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/URLRequest.html#method

大意就是存取的表單要是沒有內容的話,Flash Player就會雞婆地使用GET方法,即使你設定URLRequestMethod.POST一百遍也沒用。

所以只要有資料就行了。

因此隨便塞一些資料給URLRequest的實體:

request.data ="POST!!!";

其他一切照舊,就可以成功地發送了。

最後,就送給大家一首:Nobody

<object style="height: 390px; width: 640px"><param name="movie" value="http://www.youtube.com/v/BA7fdSkp8ds?version=3"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed allowfullscreen="true" allowscriptaccess="always" height="390" src="http://www.youtube.com/v/BA7fdSkp8ds?version=3" type="application/x-shockwave-flash" width="640"></embed></object>


圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 則留言

我要留言

立即登入留言