I got a problem - I calling cotroller function from ajax, alert
is showing but it not even going into controller function.
How could I solve this problem?
Here's my ajax function
$('#save').on('click', function() {
if (validateForm("intro2d") && validateForm("intro3d") && validateForm("text_cs")) {
intro_data = {
projectId: "@Session["projectId"]",
Image3d: "", Text3d: document.getElementById("intro3d").value,
Image2d: "", Text2d: document.getElementById("intro2d").value,
ImageCs: "", TextCs: document.getElementById("text_cs").value
};
var _intro = JSON.stringify(intro_data);
$.ajax({
type: "POST",
// async: false,
url: 'Introduction/SetIntroductionData',
data: {
projectName:"@Session["projectName"]",
intro: _intro
},
success: function (){
alert("success");
},
});
}
});
Heres the controller:
[HttpPost]
public ActionResult SetIntroductionData(string projectName, Intro intro){
using (ISession session = NHibernateHelper.OpenSession()){
var exists = session.Query<Intro>().SingleOrDefault(x => x.Project.Id == intro.Project.Id);
if (exists != null){
return Json("exist");
}
session.Save(intro);
// return Redirect(Url.Action("Index", "Data", new { projectId = project.Id }));
return Json("success");
}
}