Asp.net jquery ajax调用web服务 [英] Asp.net jquery ajax call web service
问题描述
< !DOCTYPE html >
< html xmlns = http://www.w3.org/1999/xhtml >
< head >
< title > < / title >
< script src = jquery-1.12.0.min.js > < / script >
< script src = Lash.js > < / script >
< / head >
< body >
名字< 输入 id = txtFirstname type = text / > < br / >
姓氏< 输入 id = txtLastname type = text / < span class =code-keyword>> < br / >
电子邮件< input id = txtEmail type = text / > < span class =code-keyword>< br / >
密码< 输入 id = txtPassword type = 密码 / > < br / >
< 输入 id = btnRegister type = 按钮 value = 注册 / > < br / >
< / body > ;
< / html >
$( document )。ready( function (){
$( #btnRegister)。click( function (){
Register() ;
});
function 注册(){
$ .ajax({
类型: GET,
contentType: application / json; charset = utf-8,
url: http:// localhost:4780 / WebServiceRegistering.asmx / Registering / 8,
contentType: application / json,
datatype: json,
成功:功能(数据){
alert(data);
},
错误: function (数据){
alert( 错误aaaaaaa);
}
});
}
});
[WebMethod]
public string注册( int Id)
{
return { \ registerPachage\:{\ Id\:26}}跨度>;
}
我的尝试:
我是Ajax Jquery的初学者,我正在锻炼以提高我对它的了解。我想点击#btnRegister时返回{\registerPachage \:{\Id \:26}}来自web serice
< blockquote>( document )。ready( function (){
( #btnRegister)。click( function (){
Register();
});
function Register(){
.ajax({
type: GET,
contentType: application / json; charset = utf-8 ,
url: http:// localhost:4780 / WebServiceRegistering.asmx /注册/ 8,
conten tType: application / json,
datatype: json,
成功:功能(数据){
警报(数据);
},
错误: function (数据){
alert( 错误aaaaaaa);
}
});
}
});
[WebMethod]
public string注册( int Id)
{
return { \ registerPachage\:{\ Id\:26}}跨度>;
}
我的尝试:
我是Ajax Jquery的初学者,我正在锻炼以提高我对它的了解。我想点击#btnRegister时返回{\registerPachage \:{\Id \:26}}来自网络服务
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="jquery-1.12.0.min.js"></script>
<script src="Lash.js"></script>
</head>
<body>
first name <input id="txtFirstname" type="text" /><br />
last name <input id="txtLastname" type="text" /><br />
E-mail <input id="txtEmail" type="text" /><br />
password <input id="txtPassword" type="password" /><br />
<input id="btnRegister" type="button" value="Register" /><br />
</body>
</html>
$(document).ready(function () {
$("#btnRegister").click(function () {
Register();
});
function Register() {
$.ajax({
type: "GET",
contentType: "application/json; charset=utf-8",
url: "http://localhost:4780/WebServiceRegistering.asmx/Registering/8",
contentType: "application/json",
datatype: "json",
success: function (data) {
alert(data);
},
error: function (data) {
alert(" Error aaaaaaa");
}
});
}
});
[WebMethod]
public string Registering(int Id)
{
return "{\"registerPachage\":{\"Id\":26}}";
}
What I have tried:
I'm a beginner in Ajax Jquery and I'm doing exercise to improve my knowledge about it. i want when I click #btnRegister return this "{\"registerPachage\":{\"Id\":26}}" from web serice
(document).ready(function () {
("#btnRegister").click(function () { Register(); }); function Register() {
.ajax({ type: "GET", contentType: "application/json; charset=utf-8", url: "http://localhost:4780/WebServiceRegistering.asmx/Registering/8", contentType: "application/json", datatype: "json", success: function (data) { alert(data); }, error: function (data) { alert(" Error aaaaaaa"); } }); } }); [WebMethod] public string Registering(int Id) { return "{\"registerPachage\":{\"Id\":26}}"; }
What I have tried:
I'm a beginner in Ajax Jquery and I'm doing exercise to improve my knowledge about it. i want when I click #btnRegister return this "{\"registerPachage\":{\"Id\":26}}" from web serice
这篇关于Asp.net jquery ajax调用web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!