jQuery AJAX call returning 403 Forbidden error when passing Rgraph image data jQuery AJAX call returning 403 Forbidden error when passing Rgraph image data ajax ajax

jQuery AJAX call returning 403 Forbidden error when passing Rgraph image data


It’s to do with mod_security (an Apache module) and the http:// part of the URL.

You have two options here,

  • Modify the Apache module
  • Client side workaround

Try removing imagedata from the form you are posting, and it should submit.

Source: 403-on-form-submit


Assuming CORS isn't the issue here (which it doesn't sound like it is given that it's working fine on your localhost and that it sounds like your POSTing to the same domain from which you received the original GET), it's likely a misconfiguration between Apache on your localhost and devbox. Given that the issue is only with your base 64 encoded image POST, it's likely too large so apache is rejecting it.

Per this SO post, try setting the following in either your php.ini:

post_max_size=20Mupload_max_filesize=20M

or in .htaccess / httpd.conf / virtualhost:

php_value post_max_size 20Mphp_value upload_max_filesize=20M

Note that I can't tell you for sure if this is the cause until you post the apache error log.


Your use of data in .post() is a little off. If you are trying to pass a JSON object as the data for the second argument of .post(), you need to properly form it into a JSON string. Try wrapping your dictionary with JSON.stringify(). It'll take your javascript value {key1: value1, key2: value2} and format it.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify

$.post("/Surveys/save_chart", JSON.stringify(  {     src     : imageData,     filename: 'tmpRadar<?php echo $us['UsersSurvey']['user_id']; ?>-<?php echo $survey['Survey']['id']; ?>.png'  }) //end stringify )//end post;