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