0

Why text() returns empty string on MyPage.aspx ? .find and .filter do find "imagesPaths" node.

<script type="text/javascript" charset="utf-8">

function MyFunction(albumNb) 
{    
//xmlContent = "<images><imagePaths>2</imagePaths><imageTitles>title1,title2,title3, 
//title4</imageTitles></images>"

$.ajax({
    url: "MyPage.aspx?albumNb=1",
    type: 'GET',
    success: function (res) {
       var xmlContent = res.xml;             
       $imagePaths = $(xmlContent).find("imagePaths").text();  //returns empty string, Why? 
       //$imagePaths = $(xmlContent).filter("imagePaths").text(); //also returns empty string 

    }
 });

}

Thank you

11
  • 1
    Have you parsed the XML yet? Commented Sep 11, 2013 at 18:52
  • Can you show us the XML that you are GETting with your AJAX call? As @tymeJV suggested, is it actually application/xml or is it simply an XML string? Commented Sep 11, 2013 at 18:53
  • 1
    what is res? is it an object? a string? you have no dataType and haven't given us the raw response therefore we have no way of knowing what you are receiving. It could be JSON, XML, Text, HTML, we don't know. Commented Sep 11, 2013 at 18:54
  • var xmlContent value is mentioned above $.ajax call Commented Sep 11, 2013 at 18:57
  • @KarenSlon It seems that xmlContent is simply an XML string. You need to turn it into an XML object. Commented Sep 11, 2013 at 18:58

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.