Ajax

Using Frontend Upload with Ajax is simple, we call the upload function with the following function:
jQuery('#feuGT_container_pickfiles').feuGTuploader("upload","*",{"mydata": mydata});

Parameters

  1. The first parameter is the action we want the plugin to take (currently only “upload” is available).
  2. The second parameter is the files extension we are accepting, separated by comma. To accept all extensions use “*”.
  3. The third parameter is a JSON object with extra parameters you wish to pass to the Frontend Upload PHP uploader ( check documentation on Frontend Upload Actions on how to hook and use them ).

Here is a basic ajax example:

First we insert a post to WordPress using Ajax and then we upload queued files to this new post.

$.ajax({
type: "POST",
url: '/myajaxfile.php',
data: data,
beforeSend: function () {
},
error: function () {
$('#main_container').html('ERROR');
}
}).done(function (data) {
var response = $.parseJSON(data);
$('#message').html(response.message);
var post_id_returned = response.post_id;
jQuery('#feuGT_container_pickfiles').feuGTuploader("upload","*",{"feugt_parent_post_ids": post_id_returned });
});

Leave a Reply