I’m trying to find the length of the xml object that is returned from an ajax request and am trying to determine if the xml in the response is 0 or not. I’ve tried to use $(xml).length, but it doesn’t seem to be working. It return 1 for length regardless of whether their was something returned or not.
Share
I think the issue is the way jQuery does the XML parsing if the content is an empty string or just the XML header,
<?xml version="1.0" encoding="UTF-8"?>then it creates an error response with anparseerrornode. I created an example here:http://jsfiddle.net/magicaj/55HQq/1/
If you can control the content on the server then I would suggest always returning at least a response node with the status in it, and then check the child size of the
responsenode:In jQuery you can check the size using: