This is an archived forum post. The information may be outdated. Contact us if you have any questions.

Empty Response - Ajax

brettm247 wrote on 2015-12-13:

I noticed the API was down for a bit today, i'm not sure if that is my issue or not. I am trying to connect to the API using Jquery and AJAX but am getting an empty response back

Here is my code: Note: {username} and {key} are replaced in my code.

$('#download').click(function () {
var content = $("#ScaleForm")[0].innerHTML;
var request = $.ajax({
url: "",
method: "POST",
contentType: "application/x-www-form-urlencoded",
headers: { 'Access-Control-Allow-Origin': '*'},
success: function(msg) {

error: function(msg) {

Is this a CORS issue or am i missing something obvious?

support wrote on 2015-12-15:

This is most likely a CORS issue as we do not implement it on our side.
brettm247 wrote on 2015-12-15:
Turned out to be a CORS issue.

I've since switched to the server handling the request.

Which leads me to... Can i pass a stylesheet using the "user_print_media" option similar to below? I am trying to include Form data users enter and when i just send the page, no filled in values are included. So i send the raw html.'/pdf', function (req, res) {
console.log('Connected to Pdf Route');
var date = new Date();
var time = date.getUTCMilliseconds();
pdf.saveToFile("pdfs/" + + time + ".pdf"),
width: "11in",
height: "8.5in",
vmargin: ".4in",
footer_html: '<div style=text-align:center;font-size:smaller;color:maroon;">\
Page %p out of %n\
});"pdfs/" + + time + ".pdf","scaleForm.pdf");
res.send(200, { msg: "completed" });

brettm247 wrote on 2015-12-15:
nm, just append links to the style sheets in the html.
virtualLast wrote on 2017-04-03:
Can anyone explain how I can get around this CORS issue, I dont understand. I am using jquery, the post works when using postman.
@brettm247 - you said you switched servers? what does that mean