jQuery Ajax GET with params using WebMethod in c#
Code Snippet:
Code Snippet:
UI:
<asp:Button ID="Button1" runat="server" Text="Call Ajax
Get" OnClientClick="AjaxCall2();" />
jQuery:
function
AjaxCall2() {
debugger;
$.ajax({
type: "GET",
url: "AjaxTest.aspx/TestAjaxCallGET?name='Radha'",
contentType:
"application/json; charset=utf-8",
dataType: "text",
async: true,
success: function
(response) {
alert("Success");
},
failure: function
(response) {
alert("failure");
}
});
}
WebMethod C#
[WebMethod]
[System.Web.Script.Services.ScriptMethod(UseHttpGet = true)]
public
static string
TestAjaxCallGET(string name)
{
return
name;
}
No comments:
Post a Comment