开发者

returning data in json with jquery?

开发者 https://www.devze.com 2023-02-02 11:10 出处:网络
var thumb = $(\'img#thumb\'); new AjaxUpload(\'imageUpload\', { action: \'upload.php\', name: \'image\',
var thumb = $('img#thumb');

    new AjaxUpload('imageUpload', {
        action: 'upload.php',
        name: 'image',
                autoSubmit:'json',
        onSubmit: function(file, extension) {
            $('div.preview').addClass('loading');

        },
        onComplete: function(file, response) {
            thumb.load(function(){
                $('div.preview').removeClass('loading');
                thumb.unbind();
            });
            thumb.attr('src',pic.response);
        }
    });

php file:

<?php
$arr = array ('pic'=>'img/img.jpg');

echo json_encode($arr)开发者_JS百科;
?>

but its not sending it back i dnt think!!! i tried using firebug, but it dnt show that its posting, to upload.php!!


I don't see that you're sending any data in your code. Take a look to the official documentation especially to data parameter.


I suspect you are looking for response.pic and not pic.response.

You are also failing to specify: header('Content-type: application/json');

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号