JSONP Support
We are working on experimental JSONP support. This will only work for GET requests.
To make a JSONP request use the following syntax:
https://api.playnice.ly/v1/project/123/item/456/show/?callback=<method_name>
If there is an error then the data returned will have a property called ‘error_message’ which will describe the error (in fact this is the same object we described on the errors page).
Example jQuery Code
We love jQuery. Here’s a JSONP example:
// simple function to run the code when the "Go" button is pressed
$("#go").click(function(){
// use the user inputted values
var username = $("#username").val();
var password = $("#password").val();
var projectId = $("#project").val();
var itemId = $("#item").val();
// define the url we want. If we add the empty callback parameter
// then jQuery knows that we want to use JSONP.
var url = "https://" + username + ":" + password +
"@api.playnice.ly/v1/" +
"project/" + projectId +
"/item/" + itemId +
"/show/?callback=?";
$.getJSON(url, function(data) {
if(data.error_message) {
alert("There has been an error: "
+ data.error_message);
} else {
alert("The item title is: '" + data.subject +
"' . It is '" + data.status + "'");
}
});
});
You can see this in action on our JSONP example page
For more information on how to use JSONP see here