Quantcast
Channel: Web API
Viewing all articles
Browse latest Browse all 4850

children could not be evaluated error - calling Web API from JQuery

$
0
0

I created a Web API and I'm sending the data back in XML format. I'm calling the API from JQuery on an HTM page. When I debug it, I get the following error the URL call.

 

[children could not be evaluated'

 

I'm calling the API as

function GetSales() {
        var url = "http://localhost:2222/api/Sales/GetAllPending";$.ajax({
            url: url,   //error comes here
            type: "GET",
            dataType: "xml",
            success: function (response) {
                xmlParser(response);
           },
            error: function () {
                alert("unable to process data at this time");
            }
        });
    }

 function xmlParser(response)
    {
       var xml = $.parseXML(response);$(xml).find("Sales").each(function () {$(".salesPending").append($(this).find("SalesPerson").text()
           );
        });
    }

my XML looks like this

<ArrayOfPendingSales xmlns="http://schemas.datacontract.org/2004/07/myAPI.Models" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">-<Sales><SalesPerson>Ben Smith</SalesPerson><Client>BMW</Client><Pending>45,000</Pending></Sales><Sales><SalesPerson>David Carr</SalesPerson><Client>Dupont</Client><Pending>125,000</Pending></Sales></ArrayOfPendingSales>

do I need to parse the XML in another way?

I'm using the internal IIS server in Visual Studio due to I don't have IIS on my local box at this time, could that be the issue? I'm able to run and view the data in the API in the browser and the URL has been the same since I built the API yesterday


Viewing all articles
Browse latest Browse all 4850


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>