I'm trying to send some text to Github's markdown API and get back a raw HTML representation of it.
Currently I have this code:
$.ajax({
type: "POST",
dataType: "jsonp",
processData: false,
url: "http://api.github.com/markdown/raw",
data: {
"text": $('#some_textarea').val()
},
success: function(data){
console.log("success!");
console.log(data);
},
error: function(jqXHR, textStatus, error){
console.log(jqXHR, textStatus, error);
}
});
but I get "error" (textStatus in error callback). What am I doing wrong?
textStatusis "error", nothing more and nothing less. Also, the value oferroris empty string.<script>tag to the document. jQuery is probably doing the JSONP request as asked, which is not understood by the API.dataType: "json", then jQuery will try to parse the response as JSON, which will fail. And if the API does not support CORS (but I seem to remember it does), you cannot make an Ajax request to it from the browser anyway.