开发者

Addressing different File in Different Directory

$.ajax({
type: "GET",
 url: "Administrator\Questions.开发者_运维百科xml",//folder Administrator   
success: parseXml
});



function parseXml(xml)
{
  $(xml).find("Question").each(function()
  {  
    $('#<%=sctQuestion.ClientID %>').
      append($("<option></option>").
      attr("value",$(this).find('Text').text()).
      text($(this).find('Text').text())); 
  });
}

1. does not found xmlFile;

but if copy XMLFile To Root Project and url:Questions.xml then Found XMLFile

2. when found file and add option to select

row 1: 'SPACE'

row 2: DATA

row 3:DATA

how remove 'space' in Row1

3. how is Addressing different File in Different Directory by jquery and asp.net


  1. Instead of url Administrator\Questions.xml use Administrator/Questions.xml. Backslashes are not used in URLs. Also, even if used, it would have to be Administrator\\Questions.xml - because of special meaning of backslash in javascript strings.

  2. To remove 'SPACE' use this:

    function parseXml(xml)
    {
        $(xml).find("Question").each(function()
        {  
            var value = $(this).find('Text').text();
    
            if (value.toUpperCase() !== "SPACE")
                {
                $('#<%=sctQuestion.ClientID %>').
                    append($("<option></option>").
                    attr("value", value).
                    text(value);
            }
        });
    }
    
  3. The type of directory separators used by ASP.NET is determined by underlying operating system. In Windows it's backslash. The type of separators used in URLs is forward slash. That's what jquery uses in its $.ajax function argument for urls.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜