Uncaught SyntaxError: Unexpected token < in sol

2019-09-18 19:40发布

问题:

I am trying to add a new document in the solr server. My Code

$.ajax({
            type: "POST",
            url: "http://192.168.10.113:8080/solr/update/json?commit=true",
            data: { "add": { "doc": { 'id': '19990' } } },
            dataType: 'jsonp',
            crossDomain: true,
            jsonp: 'json.wrf',
            success: function (data) { alert(data); },
            failure: function (errMsg) {
                alert(errMsg);
            }
        });

My Solr server is hosted in different domain so i wrote

 dataType: 'jsonp',
 crossDomain: true,
 jsonp: 'json.wrf',

to over come from cross domain problem.

Now it is showing Uncaught SyntaxError: Unexpected token < Error I searched on Google. maximum of experts suggested that to check in the html and js code. I checked its fine.No extra < symbol is there. Error Image

After that i changed the URL from http: //192.168.10.113:8080/solr/update/json?commit=true to http: //192.168.10.113:8080/solr/update/xml?commit=true

now its showing error link this

GET http: //192.168.10.113:8080/solr/update/xml?commit=true&json.wrf=jQuery1710918970147613436_1351693492662&add%5Bdoc%5D%5Bid%5D=19990&_=1351693497692 405 (Method Not Allowed)

Please help me to solve this problem.

Thanks

回答1:

This was showing Uncaught SyntaxError: Unexpected token < error because the server is sending xml data.

Declare json as input parameter.So I set the server as json,so that this type of error will not occur.