Take the 2-minute tour ×

I have my canvas represented as a base64 string. I would like to pass this string to the server so that the server may craft a PDF document using the data.

I receive a 414 error when I attempt to pass the data to the server: 'Failed to load resource: the server responded with a status of 414 (Request-URI Too Long).

I have successfully downloaded the image client-side. I have no problems actually retrieving and downloading the image, only in shaping the file type it is represented in.

$('#ExportPlanView').click(function (e) {
    //planViewStage.toDataURL(function (e) { window.location = e.replace("image/png", "image/octet-stream")});
    planViewStage.toDataURL(function (dataURL) {
        var output = dataURL.replace(/^data:image\/(png|jpg);base64,/, "");

            url: '../PlanView/ExportAsPDF',
            data: { DataURL: output },
            datatype: 'json',
            success: function (stream) { window.location = stream; }

Is the proper solution to break output into smaller chunks and send each chunk to the server, have the server reconstruct these chunks, craft the pdf, then send that file stream back to the client to trigger the download?

For reference -- the data URL is ~105k characters.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Use a POST request when you need to pass large amounts of data. $.ajax defaults to GET, so you need to define the type manually.

To send a POST request with jQuery, you can use something like this:

    url: 'blah.php',
    type: 'POST',
    data: { DataURL: output },
    datatype: 'json',
    success: function() { ... }
share|improve this answer
Could you explain why this changes things? –  Sean Anderson Mar 8 '12 at 23:52
A POST request can contain a separate "body" in addition to just the URL. Data in a POST request is sent in the body which is not as limited in size as the query string. Typically the default max size for POST body in PHP is something like 8 megabytes. –  Jani Hartikainen Mar 8 '12 at 23:56

Your Answer


