I'm trying to do a simple Ajax call to register a user from a HTML page, the function in the MVC 4 is called and working well, but what it returns never fires the 'success' function in the Ajax call.
If I'm using my browser to manually access the Register() function, it works well and returns the message I want, but not through Ajax
function register() {
var userModel = {
phoneNumber: "1236663",
displayname: "yasuuu",
}
$.ajax({
type: "POST",
url: "http://localhost:13234/home/register",
data: userModel,
success: function (response) {
$('#deleteThisDivButNotItsContent').html(response)
}
})
}
public ActionResult Register(string PhoneNumber, string DisplayName)
{
// Some working code here ...
ViewBag.Message = "Some Message"; // just trying to display simple text
return View();
/* tried all of the lines below too */
//return this.Json("1234");
//return Json("{ result : true }");
//return PartialView("ShowResultPartial", JsonRequestBehavior.AllowGet);
//CommentSection commentSection = new CommentSection();
//return PartialView("CommentSection");
//return PartialView("CommentSection", commentSection);
//return Json(new { success = true, response = "Saved ok" });
}
I'm using JQuery 2.0.3