Error 500 posting http request from javascript

  • Hello,
    I'm new to jsreport;

    I created a simple report in JSreport online, then from an html / javascript page I want to call the reporting engine.

    This is my actual javascript code for the request

                                type: "POST",
                                url: '',
                                contentType: 'application/json',
                                dataType: 'json',
                                data: {
                                    "template": { "shortid" : "HJI-R8mz-"  },
                                    "options": { timeout: 60000 }
                                beforeSend: function (xhr) {
                                    xhr.setRequestHeader ("Authorization", "Basic " + btoa('viewer:12345678'));
                                success: function( data ) {
                                    console.log( data );

    To simplify the process for the moment I decided to avoid passing data to the report.
    Anyway I'm always getting error 500 from the browser and exactly this message in chrome console

    XMLHttpRequest cannot load No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://sample.local:8090' is therefore not allowed access. The response had HTTP status code 500.

    For your information sample.local:8090 is the url of the web application running locally on my pc in a xampp environment.

    Please help me understand where I'm going wrong!!

  • This is some kind of jquery weird implementation of CORS, because the native xmlhttprequest works find for me in this scenario.

    You have these options:

    1. Google out the jquery CORS errors
    2. Use native xmlhttprequest to do the request, it is just like 10 lines of code
    3. Use our jsreport official client for browser -
    4. Proxy requests to jsreportonline through your server

Log in to reply

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.