Ajax Not Firing

Hello,

Advance Thanks to all. I’m trying to fire a server method from client end using ajax but its not firing. It goes to the error portion in the jquery method.

———–My jquery code:————

function ShowCurrentTime() {
var userRole = "";
$.ajax({
type: "POST",
url: "/Contact.aspx/GetCurrentTime", //tried "Contact.aspx/GetCurrentTime", "Contact/GetCurrentTime" , ‘@Url.Action("Contact.aspx", "GetCurrentTime")’ too

data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
async: false,
success: function (data) {
// userRole = msg.d;

alert("ddddd");
},
error: function (result) {
alert("Error");
}
});
return userRole;
};

———-My C# code:———–

[WebMethod]
public static string GetCurrentTime()
{
string msg="Hello " ;
return msg;
}

————Some issues you may need———-
1. I’m using VS 13
2. Using FriendlyUrl

Moloy_a

I’m trying to fire a server method from client end using ajax but its not firing. It goes to the error portion in the jquery method.

That means it is firing. However,examine

result

in developer tools. What kind of error it is?( maybe 500 – internal server error?)

Leave a Reply