0
votes

I am trying to make an Ajax call to hit a webservice and get the response.But getting uncaught syntaxerror:unexpected token < in google chrome console. Here's my Ajax Request:

$(document).ready(function(){
    $.ajax({
       url:"http://10.10.1.5:8089/axis2/services/cmtlpmservice/getAllMonitors",
       dataType:"jsonp",
       jsonpCallback:"callback",
       type:"GET",
       success:function(response){
           console.log(response);
       }
    });
});

The Request header is as follows:

Request URL:http://10.10.1.5:8089/axis2/services/cmtlpmservice /getAllMonitors?callback=callback&_=1487912464838
Request Method:GET
Status Code:200 OK
Remote Address:10.10.1.5:8089

Accept:/
Accept-Encoding:gzip, deflate, sdch
Accept-Language:en-US,en;q=0.8
Authorization:Basic YWRtaW46
Cache-Control:max-age=0
Connection:keep-alive
Host:10.10.1.5:8089
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36

The Response Header as follows:

Cache-Control:no-cache
Content-Type:application/xml;charset=UTF-8
Date:Fri, 24 Feb 2017 05:01:05 GMT
Expires:Thu, 01 Jan 1970 10:00:00 EST
Pragma:No-cache
Server:Apache-Coyote/1.1
Transfer-Encoding:chunked
X-Powered-By:Servlet 2.5; JBoss-5.0/JBossWeb-2.1

The Response looks like :

<ns:getAllMonitorsResponse xmlns:ns="ws.core.dorado.com">
 <ns:return> 
{
    "monitors": [{
        "id": "com.dorado.broadscope.monitor.Monitor::R‌​GNEXGvol54w2a#_1.3.6‌​.1.4.1.20138.800.20.‌​12.1.9.1",
        "maxAttrNa‌​me": "ifTemperatureVa‌​lue Max",
        "name": "ifTemperatureValue",
        "minAttrName": "ifTemperatur‌​eValue Min",
        "maxAttrId": "com.dorado.broadscope.monitor.Monitor::RGN‌​EXGvol54w2a#_1.3.6.1‌​.4.1.20138.800.20.12‌​.1.9.1Max",
        "minAttrI‌​d": "com.dorado.broad‌​scope.monitor.Monito‌​r::RGNEXGvol54w2a#_1‌​.3.6.1.4.1.20138.800‌​.20.12.1.9.1Min"
    }]
}

 </ns:return> 
</ns:getAllMonitorsResponse>
1
I suspect your webservice isn't returning a valid JSON response.scoota269
This is how my response looks like :<ns:getAllMonitorsResponse xmlns:ns="ws.core.dorado.com"> <ns:return> {"monitors":[{"id":"com.dorado.broadscope.monitor.Monitor::RGNEXGvol54w2a#_1.3.6.1.4.1.20138.800.20.12.1.9.1","maxAttrName":"ifTemperatureValue Max","name":"ifTemperatureValue","minAttrName":"ifTemperatureValue Min","maxAttrId":"com.dorado.broadscope.monitor.Monitor::RGNEXGvol54w2a#_1.3.6.1.4.1.20138.800.20.12.1.9.1Max","minAttrId":"com.dorado.broadscope.monitor.Monitor::RGNEXGvol54w2a#_1.3.6.1.4.1.20138.800.20.12.1.9.1Min"}]} </ns:return> </ns:getAllMonitorsResponse>Pallavi Sarawgi
What does the response body look like? You've only shown the header.nnnnnn
I'm with @scoota269 - your server is responding most likely with a regular webpageJaromanda X
@PallaviSarawgi not only is that not JSON, it's not JSONP either (which you would need for your request for jsonp to work)Jaromanda X

1 Answers

0
votes

Due to some error in getAllMonitors it returns whole html page instade of json deta in response. your controller is culpit insted of your ajax.