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
Instead of url
Administrator\Questions.xml
useAdministrator/Questions.xml
. Backslashes are not used in URLs. Also, even if used, it would have to beAdministrator\\Questions.xml
- because of special meaning of backslash in javascript strings.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); } }); }
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.
精彩评论