0
我在Mozilla和IE中可以正常工作,但由于某种原因不能使用Chrome浏览器。在chrome中,每次返回错误代码为0时,都会执行错误回调。很多关于Stackoverflow的文章不断重申所有主流浏览器如何通过AJAX而不是表单支持“PUT”方法。 Chrome似乎是例外.....通过AJAX无法在Google Chrome中使用的放置方法
的JavaScript
function works(){alert("working");} // just a success callback
$(document).ready(function(){
$("#crudForm").submit(function(){
$.ajax({url:"/UtilityDashboard/MeasurementNodes",
data:parseFormData("crudForm"),
cache: "false",
async: "false",
dataType: "text",
contentType: "application/x-www-form-urlencoded",
type:"put",
success: works(),
error:function(xhr){alert(xhr.status + xhr.statusText);} });
});
});
HTML
<form id="crudForm">
Name<BR/>
<input type="text" name="name"/><BR/><BR/>
Node Id<BR/>
<input type="text" name="node_id"/><BR/><BR/>
Type<BR/>
<input type="text" name="type"/><BR/><BR/>
Parent<BR/>
<input type="text" name="parent_id"/><BR/><BR/>
Longitude<BR/>
<input type="text" name="longitude"/><BR/><BR/>
Latitude<BR/>
<input type="text" name="latitude"/><BR/><BR/>
Description<BR/>
<textarea name="description" rows="5" cols="40">Insert description of measurement node here</textarea><BR/><BR/>
<input type="submit" value="Add Node"/>
</form>
看看这个:http://stackoverflow.com/questions/3378894/html5-put-delete-methods-not-working-in-chrome – theintersect
谢谢,但该文章只适用于
这在Chrome中适用于我。 21.0.1180.89分布。 – Ohgodwhy