0

I'm using Jquery File Upload plugin. How can I get the category_id varibale (in processstop callback function) and passing it into done callback function.

jupload.fileupload({
    url: 'upload.php',
    acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
    maxFileSize: 1536000,
    autoUpload: true,
    processfail: function(e, data){
        alert(data.files[data.index].error);
    },
    processstop: function (e, data) {
        // Create a category
        $.post('add_category.php',{'thumbnail':''},function(data) {
            var json = data,
                obj = JSON && JSON.parse(json) || $.parseJSON(json);

            // CATEGORY ID
            var category_id = obj.id;
        });
    },
    done: function (e, data) {
        // HOW CAN I GET THE `category_id` ABOVE TO USING ADD PRODUCT?

        // Add products to category
        $.post('product_add.php',{'category_id':category_id},function(data) {
            /* ...... */
        });
    }
});

1 Answer 1

1

The simplest way is to define category_id above your jquery file uploader initializer.

var category_id;
jupload.fileupload({
...
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.