asp.net mvc making ajax call jason
- by mazhar kaunain baig
Controller:
public ActionResult EditOrganizationMeta(int id)
{
}
[HttpPost]
[ValidateInput(false)]
public ActionResult EditOrganizationMeta(FormCollection collection)
{
}
View:
function DoAjaxCall() {
var url = '<%= Url.Action("EditOrganizationMeta", "Organization") %>';
//url = url + '/' + dd;
$.post(url, null, function(data) {
alert(data);
});
}
<input type="button" name="something" value="Save" onclick="DoAjaxCall()" />
how would i make the ajax call , i have basically two functions with the same name EditOrganizationMeta,Do the form collection will be passed automatically.Basic confusion is regarding the method call
Ok i made a call by ajax but after that My This code is not running anymore
[HttpPost]
[ValidateInput(false)]
public ActionResult EditOrganizationMeta(FormCollection collection)
{
int OrganizationId = 11;
string OrganizationName = "Ministry of Interior";
try
{
string ids = Request.Params // **getting error here some sequence is not there**
.Cast<string>()
.Where(p => p.StartsWith("button"))
.Select(p => p.Substring("button".Length))
.First();
String RealValueOfThatControl = collection[ids];
}
}
catch { }
return RedirectToAction("EditOrganizationMeta", new { id = OrganizationId });
}
I think that there is no post