How can I pass a parameter to the server (MVC)
How can I pass a parameter to the server (MVC)
rshun
Posts: 44Questions: 9Answers: 0
Hi,
I am using following javsscript to send ajax request to server
var editor = new $.fn.dataTable.Editor({
ajax: "@Url.Action("Test")",
table: "#example",
fields: [{
...
}];
How can I pass a parameter to the server (MVC)?
public ActionResult Test(String parameter)
{
...
}
Can I use the following way to pass parameter in JSON?
var editor = new $.fn.dataTable.Editor({
ajax: function (method, url, data, success, error) {
$.ajax({
type: 'Post',
url: "@Url.Action("Test")",
data: parameter,
dataType: "json",
success: function (json) {
success(json);
},
error: function (xhr, error, thrown) {
error(xhr, error, thrown);
}
})
},
table: "#example",
fields: [{
...
}];
Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
To send parameters to the server, you can use
ajax.data
- there are a few examples on that page that should get you going,Colin