close

http://www.dotblogs.com.tw/hatelove/archive/2009/12/22/jqueryajax.aspx

http://stackoverflow.com/questions/8951810/how-to-parse-json-data-with-jquery-javascript

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(function () {
var ID = $('#ID').val();
var middleName = $('#MiddleName').val();
$.ajax({
type: 'post',
url: "Handler.ashx",
data: "ID=" + ID + "&MiddleName=" + middleName,
success: function (name) {
$('#按鈕').val(name);
console.log('d');
},
error: function () {
alert('ajax failed');
}
})

})
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input type="text" id="ID" value="3" />
<input type="text" id="MiddleName" value="4" />
<input type="button" id="按鈕" value="按鈕" />
</div>
</form>
</body>

 

.ashx

public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
string ID = context.Request.Form["ID"];
string middelName = context.Request.Form["MiddleName"];
string lastName = "Chang";
string Name = ID + " " + middelName + " " + lastName;
context.Response.Write(Name);
}

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 amychang2014 的頭像
    amychang2014

    工作需要筆記

    amychang2014 發表在 痞客邦 留言(0) 人氣()