asp.net mvc ajax how to pass the id as well to the controller
function submitForm(frm) {
var tdata = $(frm).serialize();
$("#loader").show();
$.ajax({
url: "/abc1/abc",
开发者_如何学C data: tdata + "&id=" + id,
i am having problem passing in passing the url id to the controller with the form . how can i do that ?
be more specific in posting question by reading your question it is difficult to understand what you are asking.
do you want to pass multiple parameter to your controller is it the case.
If yes than do some thing like this
urldata = "name=" + OS_Name + "&desc=" + OS_Description;
data: urlData,
If some thing else clarify it more clearly
Since you're using MVC you could do something like that:
url: '<%=Url.Action("Action", "Controller")%>'
,
and pass the data this way:
data: { id: yourId },
If your controller receives more than one parameter you can extend it like this:
data: { id: yourId, param2: otherParam, param3: newOne },
Problem here is that data is javascript object, not a string, so you should be passing the query parameters like this: data: {param1:'param1value', param2:'param2value'}
I hope this makes sense!
精彩评论