I have this working fine in Mozilla and IE but for some reason not chrome. In chrome, the error callback executes every time returning an error code of zero. Lots of articles on Stackoverflow keep reiterating how all major browsers support the "PUT" method through AJAX instead of forms. Chrome appears to be the exception.....
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>