jQuery Ajax call returning '[object XMLDocument]'

后端 未结 5 488
闹比i
闹比i 2021-02-01 23:06

I have an HTML page which I want to populate using Ajax. I\'ve copied code from other pages, (which are all in PHP, and I\'m not sure if that matters), and it\'s returning

5条回答
  •  长发绾君心
    2021-02-02 00:12

    You just need to tell the datatype(which direct the browser you are expecting response in the mentioned format only,e.g.: "text" format) . In this case I tested this in firefox and mozilla.and it works.. :)

    Check the Response in firefox/Mozilla - you can also verify the coming response after ajax request... follow the below steps-- press F12 in firefox/mozilla --> go to "Console" tab --> go to "Response" sub tab. :)

    function GetEmployeeListWS_REST() {        
                jQuery.ajax({
                url: "http://localhost:8080/RESTDemo/rest/hello/helloXML",
                async: false,
                type: 'GET',
                contentType: "text/xml; charset=utf-8",                
                dataType: "text",
                 crossDomain: true,
                //data: packet,
                error: function (xhr, textStatus, errorThrown) { alert(xhr + ' ' + textStatus + '' + errorThrown); },
                success: function (response, status, xmlData) {
    
                    $("#EmployeeDetailsWs").text(response);                    
                }
            });
    
        } // ends : fun()
    

提交回复
热议问题