简体   繁体   中英

Post data don't send using jQuery Ajax request

how to send large base64 data Array using jQuery Ajax. Here is my code :

$.ajax({
        type: "POST",
        url: "addPhoto.php",                                
        data:{photosArray:photosArray},
        dataType: "json",           
        success: function(data) {                   
                 $(data).each(function(){
                     ...
                 });
        }           
});

photosArray contains between 3 and 12 very long strings like :

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAMAAAC6V+0...

Is there any limit for POST data size in Ajax?

Open your php.ini file and find the line stating upload_max_filesize. The default it set to 2M, which is 2MB. Try increasing it to 3MB and see if you are still receiving the error. And use

      "cache": false

Is your data properly declared ? It can be either String, object or array. try following

$.ajax({
  type: "POST",
    url: "addPhoto.php",                                
    data:"{photosArray:photosArray}",
    dataType: "json",           
    success: function(data) {                   
             $(data).each(function(){
                 ...
             });
    }      
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM