Jump to content









Photo

CORS, jquery, and jsonp?

CORS jquery jsonp

  • Please log in to reply
2 replies to this topic

#1 sevenkev

sevenkev

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 16 April 2014 - 06:54 PM

Does the API support cross-domain CORS requests from jquery?  These requests return OK in postman, but when formulating a jQuery getJson or ajax request the apikey gets stripped from the header.  

 

What is the proper syntax for sending a cross-domain jQuery request to the Carriots API?  Does the API support jsonp?

 

Thanks very much. 



#2 sdeancos

sdeancos

    Master of Puppets

  • Members
  • PipPipPip
  • 105 posts
  • LocationMadrid, Spain.

Posted 22 April 2014 - 04:06 PM

Hi!

 

Currently it's not implemented but this is in our roadmap and soon will be working.

 

At the moment is only possible send streams by CORS.

 

 

I hope this can help you, and if you have any doubt don't hesitate to ask here.



#3 sdeancos

sdeancos

    Master of Puppets

  • Members
  • PipPipPip
  • 105 posts
  • LocationMadrid, Spain.

Posted 21 May 2014 - 08:35 AM

Hello World!

 

Today we implemented CORS, you can try our API with JS.

 

For example:

 

    function callbackAjax(text, status) {
        document.getElementById("response").innerHTML = text;
    }

    function callAjax(url, callback) {
        var xmlhttp;
        xmlhttp = new XMLHttpRequest();
        xmlhttp.onreadystatechange = function(){
            callback(xmlhttp.responseText, xmlhttp.status);
        }
        xmlhttp.open("GET", url, true);
        xmlhttp.setRequestHeader('carriots.apikey', 'YOU_APIKEY_HERE');
        xmlhttp.send();
    }

    callAjax('https://api.carriots.com/projects/', callbackAjax);

 

 

Enjoy Carriots!






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users