Jump to content

why is this POST request no AJAX request?


bernhard
 Share

Recommended Posts

hi devs,

i have an uikit drag&drop upload on my project and it's working fine. i have this request in my dev-tools:

post-2137-0-11596800-1456836189_thumb.pn

it sends a POST with the image data and returns a smaller version of the image (GET)

in my php-code i handle it like this (some lines collapsed):

post-2137-0-30778400-1456836291_thumb.pn

can someone explain what exactly counts as $config->ajax request and what does not? thank you!

Link to comment
Share on other sites

According to his screenshot both requests are XHR (XMLHttpRequest), so it should be seeing them as such.

I assume you're doing your call with jQuery? Do you have any proxy between the browser and the server like CloudFlare that might interfere with it?

  • Like 1
Link to comment
Share on other sites

thank you pierre-luc. yes that's why i thought it should be an $config->ajax request...

this is the code for the upload via uikit:

/**
 *
 * stickerframeupload
 *
 */
var progressbar = $("#stickerframeprogressbar"),
    bar         = progressbar.find('.uk-progress-bar'),
    settings    = {
        action: config.pageUrl + 'setstickerframe/', // upload url
        single: false, // make one request per file = true/false
        filelimit: 1,
        params: {width: $('#stickerframemodal .rahmen').width()},
        //allow : '*.(png)', // allow only PNG images
        loadstart: function() {
            bar.css("width", "0%").text("0%");
            progressbar.removeClass("uk-hidden");
        },
        progress: function(percent) {
            percent = Math.ceil(percent);
            bar.css("width", percent+"%").text(percent+"%");
        },
        allcomplete: function(response) {
            bar.css("width", "100%").text("100%");
            setTimeout(function(){
                progressbar.addClass("uk-hidden");
            }, 250);

            var res = JSON.parse(response);
            config.stickerframetmp = res.stickerframe;
            config.stickerframepreviewtmp = res.stickerframepreview;
            $('#stickerframemodal .rahmen').attr('src',res.stickerframepreview);
        }
    };
var select = UIkit.uploadSelect($("#stickerframeinput"), settings),
    drop   = UIkit.uploadDrop($("#stickerframedrop"), settings);

here is the info about uikit drag&drop upload: http://getuikit.com/docs/upload.html

yes, jquery; no proxy...

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...