I have tried for hours to get this working, and I am really hoping one of you knows (a heck of a lot) more about this than I. When the client keys up in a textbox, I would like to call the MVC C# controller method called updateOrder(). Ideally, I would like to access form elements with a FormCollection (the form is called "createOrder").
In the controller, I have:
C#
[WebMethod]
public static void updateOrder(){
string s = "asdf";
}
The string declaration above is breakpointed. In the view, I have a method I basically copy and pasted that I found on stackoverflow:
JavaScript
function updateOrderJS() {
var $form = $('form[id="createOrder"]');
$.ajax({type : "POST",
url : $form.attr('action'),
data : $form.serialize(),
error : function(xhr, status, error) {},
success : function(response) {
updateOrder();
}
});
return false;
}
The event is simply:
JavaScript
updateOrderJS();
The updateOrderJS() method fires (checked with an alert), but the breakpoint does not.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…