c# - 如何从Web服务生成的客户端应用程序引用XML文件

标签 c# javascript xml jquery

这是我在 Web 服务上的代码,它成功创建了 xml 文件并保存在特定的目标文件夹中。

public bool GetList(string keyword1, string streetname, string lat, string lng, string radius)
{

  XmlDocument xmlDoc=  CreateXML( keyword1,streetname,lat,lng,radius);
  xmlDoc.Save(@"C:\Documents and Settings\block\Block3.xml");
  return true;

}

我正在尝试使用以下代码从客户端应用程序读取该文件,但我遇到了一些问题。

$.ajax({
                type: "POST",
                async: false, 
                url: "/block/JsonWebService.asmx/GetList",
                data: keyword2,
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                failure: ajaxCallFailed,
                success: ajaxCallSucceed

            });
            });

function ajaxCallSucceed(response) {
            if (response.d == true) {
               searchLocationsNear();
            }
            else {
                alert("can not save");
            }
        }
function searchLocationsNear() {
            var radius = document.getElementById('radiusSelect').value;

            var searchUrl ="Block3.xml";// is this the correct way to refer to the 
                                                xml file stored in app folder    
            GDownloadUrl(searchUrl, function(data) {
                var xml = GXml.parse(data);
                      ........................................
                      .......................................

最佳答案

您的网址应该是网络上的完整路径

例如 var searchUrl ="http://yourdomain/Block3.xml";

我发现您正在将文件保存在文档和设置中。您不应该将其保存在该位置。

关于c# - 如何从Web服务生成的客户端应用程序引用XML文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3636338/

相关文章:

c# - Mod_Mono + ASP MVC 5 Framework 4.5 - System.Web.Security.MembershipPasswordAttribute 错误

javascript - 为什么我的 Jasmine 测试在这个指令上失败了?

Javascript运行密集型可视化操作而不卡住浏览器

xml - 宏 VBA Excel 创建 XML 文件日期

xml - 如何在ehcache配置文件中注入(inject)属性?

php - 将输出保存为 .xml 格式

c# - C# 中的简单 3D 渲染

c# - DbLinq 的对象跟踪的性能可以提高吗?

c# - 调用JSON web服务时如何获取异常信息

php - 我应该选择 AJAX 和 JQuery 的复杂性和速度还是 GET 的简单性?