Created
June 19, 2017 20:38
-
-
Save yaplex/2110cfc1b612c22e6c7cf5bfd6839986 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" | |
Inherits="WebApplication1._Default" %> | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head runat="server"> | |
<title></title> | |
<script src="jquery-1.3.2.js" type="text/javascript"></script> | |
<script src="jquery-1.3.2-vsdoc.js" type="text/javascript"></script> | |
<script type="text/javascript"> | |
function cityClickJQuery() | |
{ | |
$.ajax({ | |
type: "POST", | |
url: "http://localhost:65424/CityService.svc/DoWork", | |
data: '{"userName":"'+$get("txtName").value+'"}', | |
processData:false, | |
contentType: "application/json; charset=utf-8", | |
dataType: "json", | |
success: function(data) | |
{ | |
alert(data.d); | |
} | |
}); | |
} | |
function cityClick() | |
{ | |
CityService.DoWork($get("txtName").value, onSuccess); | |
} | |
function onSuccess(data) | |
{ | |
if (data) | |
alert(data); | |
} | |
</script> | |
</head> | |
<body> | |
<form id="form1" runat="server"> | |
<div> | |
<asp:ScriptManager runat="server"> | |
<Services> | |
<asp:ServiceReference Path="~/CityService.svc" /> | |
</Services> | |
</asp:ScriptManager> | |
<div style="background-color:#eee;"> | |
<input type="text" name="txtName" id="txtName" /> | |
<input type="button" value="jQuery call" onclick="cityClickJQuery();" /> | |
<input type="button" value="ASP.NET AJAX Call" onclick="cityClick();" /> | |
</div> | |
</div> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment