jquery ajax 调用webservice以及跨域问题
2012-12-04 13:46 by omgee, 279 阅读, 0 评论, 收藏, 编辑
先在服务器端配置webconfig,因为默认情况下是不支持post,get访问
在system.web 中间
本地调用
客户端
$(document).ready(function () {
$("#button1").click(function () {
var p_code = $("#pcode").val();
var m_code = $("#mcode").val();
var language = 'ch';
$.ajax({
type: "post", //访问webservice使用POST方式请求
contentType: "application/json;gb2312", //WebService会返回Json类型
url: "Service1.asmx/GetData", //调用WebService方法
data: "{goods_no:'" + p_code + "',mer_no:'" + m_code + "',language:'" + language + "'}", //要传递的参数,没有传参时,也一定要写上
dataType: "json",
success: function (result) {