900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > Jquery Ajax学习实例3 向WebService发出请求 调用方法返回数据【jquery】

Jquery Ajax学习实例3 向WebService发出请求 调用方法返回数据【jquery】

时间:2020-02-22 22:42:51

相关推荐

Jquery Ajax学习实例3 向WebService发出请求 调用方法返回数据【jquery】

web前端|js教程

Jquery,Ajax学习

web前端-js教程

A、WebService.asmx

处理业务数据,在GetWhether方法中产生天气情况数据,供JqueryRequest.aspx调用,代码如下:

微收银系统源码,vscode 怎么输入,荣耀3c ubuntu,tomcat搭建iis,sqlite 表清空,全能服务器,wordpress首页图片插件,前端框架怎么解析,什么是微信公众号爬虫,怎么插PHP,seo网站的优化方案,保护环境网站模板,网页源码转码,dede后台模板目录,div页面布局,html管理系统模板下载,程序员 表白 jslzw

[System.Web.Script.Services.ScriptService]

public class WebService : System.Web.Services.WebService {

public WebService () {

//如果使用设计的组件,请取消注释以下行

//InitializeComponent();

}

[WebMethod]

public string GetWhether(string cityId)

{

Random r = new Random();

int degree = r.Next(100);

string wInfo = string.Format("Today {0}s temperature is {1} degrees", cityId, degree);

return wInfo;

}

}

B、AjaxRequest.aspx

通过点击按钮来请求WebService.asmx的GetWhether(string cityId)方法,获取天气数据。代码如下:

云购最新网站源码下载,ubuntu 到相关目录,tomcat环境变量什么用,南京爬虫定制开发,19个php教程视频全过程,隐藏图层seolzw

<input type="button" onclick="BtnCity_Click()"

style="width:55px; height:20px;" />

sd

幼儿园管理系统 源码,ubuntu配置图,利用爬虫写文章,php采集php采集器,seo42-lzw

function BtnCity_Click() {

var city = $(“#Text1”).val();

$.ajax({

url: “WebService.asmx/GetWhether”,

data: { cityId: city },

type: “post”,

success: function(data, status) {

$(“#dd”).html(“

天气情况:” + data.childNodes[1].text + “

“);

}

});

}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。