Aamir Siddique
Aamir Siddique

Reputation: 334

Error with a JSONP code. Error: "XML can't be the whole program"

I am using the following code:

function getXml(username)
{
    $.ajax({
            type:"GET",
            dataType:"jsonp",
            url: "http://76.222.193.173:8080/vvmfb/users/"+username,
            success: function(jsonp)
            {
                //alert(jsonp);
            }
        });
}
getXml('farhana');

But it is giving me this error message:

XML can't be the whole program
http://76.222.193.173:8080/vvmfb/users/farhana?callback=jQuery17108919437211861222_1326137662617&_=1326137662621
</user>
Line 12

The XML file can be seen at: http://76.222.193.173:8080/vvmfb/users/farhana

Any ideas, why is this happening? Any help would be highly appreciated. Thanks!

Upvotes: 0

Views: 544

Answers (2)

Christofer Eliasson
Christofer Eliasson

Reputation: 33865

The problem is that you are trying to receive XML with an Ajax-call that expects JSONP.

You have to decide whether to receive XML or JSONP. If it is XML that you intend to receive, then you will have to change your Ajax-call so that is expects XML as result.

Since you are specifying IP, port and the whole shebang as the URL I guess you intend do a cross-site request, and if that is the purpose why you are specifying JSONP, then you can not return XML from the server. XML is not allowed for cross-site requests due to the Same Origin Policy.

Upvotes: 2

Alnitak
Alnitak

Reputation: 339985

JSONP must supply a chunk of data that will be interpreted as Javascript by a <script> tag. It works by exploiting the weakness in the browser security model that allows <script> tags to load scripts from any domain without any Cross Origin security checks.

XML isn't that.

Upvotes: 2

Related Questions