1

I made this function to request some tickets from JIRA,I gave the data type as jsonp to avoid the Cross origin problem , and when I make the request I get the response in browser debugger , but cannot handle the json response "SyntaxError: missing ; before statement" , is there any way to read json if I send the request for jsonp ?

     var ajaxUrl = jira/rest/api...
     jQuery.ajax({
        url:ajaxUrl,
        dataType: 'jsonp',
        jsonpCallback: 'callback',
        type : "GET",
        beforeSend: function (xhr){
          success: function w(data){
            console.log(data);
            alert('Sucess data: ' + data);
          };
          error: function e(data){alert('alert error');}
        }
    })
3
  • what is the size of the file? another thing your content-type should be changed. Commented Jun 29, 2017 at 10:29
  • I am requesting a Json with about 10.000 characters Commented Jun 29, 2017 at 10:34
  • I'm not a javascript user, but shouldn't the addEventListener be called before the send function? Once you have sent the AJAX call, you may face a race condition where the return happens before you can attach the listener. Commented Jul 3, 2017 at 20:34

1 Answer 1

1

I solved the problem , I changed the jsonp in json , and I remade the corss from jira server how it is explained here : https://community.atlassian.com/t5/Answers-Developer-Questions/Enable-CORS-in-JIRA-REST-API/qaq-p/553997 , it looks like the problem was on the preflight part.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.