Simple jQuery ajax questions with successful data return?

Hi, I have the following:

         $.ajax({
           type: "POST",
           url: global.pathPrefix + '/services/brochure.asmx/ShowPostRequest',
           data: "parkIds=" + $('input.ids').val(),               
           success: function(msg){
             alert( "Data Saved: " + msg );
           },
           error: function(msg){
             alert( "error: " + msg );
           }               
         });

I expect "true" or "false" while I get "[object Document]". How to analyze this returned data? there is nothing to find out on the jQuery website. I also tried msg.d which did not return anything.

thank

+3
source share
1 answer

When you use the jQuery function .ajax, what it passes back to your callbacks depends on which response is sent. From the docs :

jQuery MIME ( XML MIME XML, 1.4 JSON JavaScript, 1.4 script script, ).

, , , script XML, jQuery XML- . , jQuery , , dataType (, dataType: "text"), , , XML, XML, , .

, XML-, , , , . jQuery XML. , , :

<?xml version="1.0" encoding="utf-8" ?>
<foo>
    <success>true</success>
</foo>

success :

success: function(xml) {
    var success = $(xml).find('success').text();
    alert(success);
}

XML jQuery:

+4

Source: https://habr.com/ru/post/1771443/


All Articles