0
$("#get-results").submit(function (event) {
    console.log("Submitting new analysis...");
    event.preventDefault();
    //$("#question-submit").prop("disabled", true);
    var question = $('#question').val();
    var url1 = "https://@gateway.watsonplatform.net/retrieve-and-rank/api/v1/solr_clusters/solr/example_collection/fcselect?ranker_id=868fedx13-rank-702&q=does it support encryption &wt=json&fl=id,title,body";
    $.ajax({
        type: "POST",
        url : url1,
        dataType : 'jsonp',
        jsonpCallback : 'callback',
    });
    // JSONP Callback
    function callback(response) {
        //var glacier = JSON.parse(response);
        alert("Response from cross origin: " + response);
    }

}); 

SyntaxError: missing ; before statement {"responseHeader":{"status":0,"QTime":70},"response":{"numFound":109,"start": |_________________^ is the response

nisarga lolage
  • 531
  • 1
  • 5
  • 14

1 Answers1

0

the response is a JSON but you are using dataType="jsonp" - jsonp is not json. Change dataType: 'jsonp' to dataType: 'json'

you should check here for more information: AJAX call and clean JSON but Syntax Error: missing ; before statement

Community
  • 1
  • 1
  • thanks crescendo.. But I'm doing cross domain request.. It's necessary to use JSONP otherwise it shows error of another domain.. What should I do – nisarga lolage Apr 09 '16 at 11:02
  • in that link there is a reference to do a cross domain request: http://stackoverflow.com/questions/3076414/ways-to-circumvent-the-same-origin-policy – Crescenzo Migliaccio Apr 09 '16 at 13:18