【发布时间】:2010-09-03 05:01:51
【问题描述】:
我有以下代码试图将 xml 构造的数据发布到 webservice .asmx 但是xml构造的数据根本没有到达webservice文件。当我进行ajax调用控制时根本没有移动到webservice文件。ajax语法有什么问题吗? 这是我在客户端的代码。
$.ajax({
type: "POST",
async: false,
url: "/blkseek2/JsonWebService.asmx/GetList",
datatype:"xml",
data:"<?xml version='1.0'?><keyword1>"+keyword1+ "</keyword1><streetname>"+address1+ "</streetname><lat>"+lat+"</lat><lng>"+lng+ "</lng><radius>"+radius+"</radius>" ,
contentType: "application/xml; charset=utf-8",
// processData: false,
failure: function(XMLHttpRequest, textStatus, errorThrown)
{ ajaxError(XMLHttpRequest,textStatus, errorThrown); },
success: function(xml)
{ ajaxFinish(xml); }
});
这是我在 webservice 中的 webmethod 代码,它试图返回 xml 文件作为请求的输出
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Xml)]
public XmlDocument GetList(string keyword1, string streetname, string lat, string lng, string radius)
{
XmlDocument xmldoc= CreateXML( keyword1,streetname,lat,lng,radius);
return xmldoc;
}
【问题讨论】: