title: Calling Java Rest API from javascript as JSONP returns invalid label error
body: <p>i have created a java webservice to return country list</p>
  
  <pre><code>@RequestMapping(value = "/getcountrylist", method = RequestMethod.GET, headers = "Accept=application/json")
  public @ResponseBody
  @ApiIgnore
  Object getcountrylist(@RequestParam String pvtToken,
          @RequestParam String lan) {
  
      System.out.println(API_TAG + "Request recevied to get CountryList");
      System.out.println("DB:"+dbName);
      if (!this.pvtToken.equals(pvtToken)) {
          CountryList countryList = new CountryList();            
          return new ResponseEntity&lt;CountryList&gt;(countryList,
                  HttpStatus.UNAUTHORIZED);
      }
      CountryList countryList = avlMobileAPIService.getCountryList(lan);      
      return new ResponseEntity&lt;CountryList&gt;(countryList, HttpStatus.OK);     
  
  }
  </code></pre>
  
  <p>i need to call the above webservice from javascript as JSONP, i wrote the following javascript code as below</p>
  
  <pre><code>function buttonClick(){
  
  $.ajax({
             type: "GET",
             dataType: "jsonp",         
             crossDomain: true,
             url: "http://localhost:8080/api/getcountrylist",
               data: {pvtToken:"JXku56AE0067YtRUSAZEE",lan:"en"},
               Accept: "application/jsonp",
               jsonpCallback:  function(data, status){
                  alert('callback');
                  alert(data);
             },              
             success: function(data, status){
                  alert('sucess');
             },
  
  
             });
  
  }
  </code></pre>
  
  <p>Above function call the webservice and returns the list, but shows "<strong>invalid label error</strong>" on client side.</p>
  
  <pre><code>{"countrylist":[{"countryId":"4","countryCodeAlpha2":"AF","countryCodeAlpha3":"AFG","countryName":"Afghanistan ","isdCode":"93"},{"countryId":"5","countryCodeAlpha2":"AL","countryCodeAlpha3":"ALB","countryName":"Albania ","isdCode":"355"},{"countryId":"6","countryCodeAlpha2":"DZ","countryCodeAlpha3":"DZA","countryName":"Algeria ","isdCode":"213"},{"countryId":"7","countryCodeAlpha2":"AS","countryCodeAlpha3":"ASM","countryName":"American Samoa ","isdCode":"684"}]}
  </code></pre>
  
  <p>i found in some article it says, the that ajax call expects JSONP , but return JSON data.</p>
  
  <p>What is the solution?</p>