简体   繁体   中英

“PUT” request gets sent via AJAX, but no data component transferred

Through AJAX your supposed to have support for the "PUT" and "DELETE" requests. I have a form that sends data via the "PUT" request and the server acknowledges it but no parameters get sent. The same result happens for the "delete" request. If I change to "post" it works fine. IE 9, Firefox, and Chrome all produce the same result. The put and delete requests are being sent but with no data.

$("#startButton").click(function(){
                $.ajax({url:"http://localhost:8084/Project/servlet",
                    data:parseFormData("simulatorForm"),
                    cache: "false",
                    dataType: "text",
                    contentType: "application/x-www-form-urlencoded",                
                    type:"put",
                    error:function(xhr){alert(xhr.status + xhr.statusText);} });
            });

NOTE: If I change to "post" this works fine. All parameters in my form get transmitted. I tried this in IE, Chrome, and Mozilla Firefox.

I tried doing it in pure javascript but I get the exact same results.

var xmlhttp=new XMLHttpRequest();
           xmlhttp.open("PUT","http://localhost:8084/UtilityDashboard/SensorSimulator",true);
           xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
           xmlhttp.send(parseFormData("simulatorForm"));

What web-server are you using? Special note about PUT/DELETE requests:

By default IIS 6 does not support PUT and DELETE verbs. To enable this, you need to add a wildcard mapping to the virtual directory of your application, this is as simple as clicking the insert button next to Wildcard application maps in your site or virtual directory properties in IIS Manager and entering the path to aspnet_isapi.dll.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM