How do I create textbox which can save any input in database using jquery Ajax in Asp.net mvc4... eg:I write "my new task" in textbox and click on button and this saves in database with "The project" id and the "UserId" which is login in application, so how can I create this in mvc4, here is my code..
public actionresult Insert(task,projectId,UserId)
{
//linq to sql here...
}
and Ajax code is
source: function(request, response) {
$.ajax({
url: pagePath + "/insert",
data: "{ 'id': '" + request.term + "'}",
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
dataFilter: function(data) { return data; },
success: function(data) {
response($.map(data.d, function(item) {
{
value = item.Name
return value;
}
}))
},
error: function(XMLHttpRequest, callStatus, errorThrown) {
alert(callStatus);
}
});
},
Is this the correct way? Can someone please guide me
source: function(request, response) {
$.ajax({
url: "controllername/actionmethodname",
data: "{task:value,projectId:value,UserId:value }",
dataType: "json",
type: "POST",
success: function(data) {
response($.map(data.d, function(item) {
{
value = item.Name
return value;
}
}))
},
error: function(XMLHttpRequest, callStatus, errorThrown) {
alert(callStatus);
}
});
},
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.