views:

20

answers:

2

This is my code on the webservice which sucessfully creates the xml file and saves at particular destination folder.

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;

}

I am trying to read that file from clientside application with the following code,but i am facing some problem with it.

$.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);
                      ........................................
                      .......................................
+1  A: 

From javascript in a browser you can't access the file system of the server (even if the server is the local host).

You probably want to save the xml file to a location that can be accessed via http request, and use that URL from your script to actually retrieve the file.

Philip Rieck
Thanks for your reply can you please help on how to store xml into location where i can be accessed by client side this my webservice code snippet[WebService(Namespace = "http://tempuri.org/")][WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)][System.Web.Script.Services.ScriptService][WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public bool GetList() { XmlDocument xmlDoc= CreateXML( keyword1,streetname,lat,lng,radius); xmlDoc.Save(@"C:\Documents and Settings\Vijay.EKO-03\Desktop\blockseek3-9-2010\Block3.xml"); return true; }
mahesh
+2  A: 

your url should be the complete path on the web

e.g. var searchUrl ="http://yourdomain/Block3.xml";

I see that you are saving the file in documents and settings. you should not save it that location.

ajay_whiz
Thanks for the reply, ya you are exactly right after constructing xml output i am saving at particular destination ,I am not clear with my webservice code where exactly i should save the xml output ,so that i can access it from client side application can you please help on this as i am very new to web application development
mahesh
@manesh you should save it in some folder in your website. Your webservice code shoudl change to `xmlDoc.Save(Server.MapPath("~/block/Block3.xml"));` and your js code will be `var searchUrl ="http://yourdomain/block/Block3.xml"`
ajay_whiz