0

I need to post large amount of json data to php file via ajax, but its is showing me 413 entity too large error. I have tried using data type as json but it still shows the same error.

$.ajax({
    url: ajaxURL,
    data: "ajax=true&action=manageSavedLayouts&a=" + result + "&b=" + encodeURIComponent(productdb),
    success: function(result) {
        console.log(result);
        //  alert(result);
    }
});

This is the code i am using to make the ajax call and the variable which is causing problem is productdb.

Any help will be greatly appreciated.

Thanks in advance.

guradio
  • 15,524
  • 4
  • 36
  • 57

2 Answers2

0
$.ajax({
    url: ajaxURL,
    type: "POST",
    data: {
        ajax: true,
        action: "manageSavedLayouts",
        a: result,
        b: productdb
    }
    success: function(result) {
        console.log(result);
    }
});
AsgarAli
  • 2,201
  • 1
  • 20
  • 32
  • i have specified type as post datatype as json and passing the content as json also but it doesn't work it still gives entity too large error..any idea why?? – Shivika Sharma May 10 '16 at 06:11
  • "413 (Request Entity Too Large)" This is the error i get in console – Shivika Sharma May 10 '16 at 06:53
  • @ShivikaSharma : What is your web-server ? – AsgarAli May 10 '16 at 07:48
  • its apache, i have increased the post_max_size also but the issue is still there – Shivika Sharma May 10 '16 at 10:04
  • type? shouldn't that be "method"? Please refer to jQuery documentation. You are having this error because there is a limit to the url size if I recall it right. And you still had the error when using "type": "post" as "type" serves to define the type of data expected from the response following the call. Using method should allow you to post the JSON. – joeyj May 11 '16 at 07:09
  • **type** (default: 'GET') An alias for `method`. You should use `type` if you're using versions of jQuery prior to 1.9.0. http://api.jquery.com/jquery.ajax/ – AsgarAli May 13 '16 at 04:54
0

Use type POST, e.g.:

$.ajax({
    url: ajaxURL,
    type: 'POST',
    data: "ajax=true&action=manageSavedLayouts&a=" + result + "&b=" + encodeURIComponent(productdb),
    success: function(result) {
        console.log(result);
    //  alert(result);
    }
});
Online Sid
  • 116
  • 4