URLRequest/URLLoader auto-converting POST request to GET

前端 未结 2 1022
傲寒
傲寒 2020-12-21 01:12

When I execute the following code:

var urlRequest:URLRequest = new URLRequest(\"http://somehost/with/some/path?andsomequerystring=true\");
urlRequest.method          


        
2条回答
  •  甜味超标
    2020-12-21 01:33

    It is because the way you are having your url. If you want to have your variables for POST method you need to use URLVariables.

    var urlRequest:URLRequest = new URLRequest(YOUR_REQUEST_URL_HERE);
    var variables:URLVariables = new URLVariables();
    variables.andsomequerystring = true;
    
    urlRequest.data = variables;
    urlRequest.method = 'POST';
    var urlLoader:URLLoader = new URLLoader(urlRequest);
    urlLoader.addEventListener(Event.COMPLETE,  function(event:Event):void{
        trace('sweet');
    });
    

提交回复
热议问题