0
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);
?>

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

4
  • im using calums ajax upload plugin by the way github.com/valums/ajax-upload Commented Jan 3, 2011 at 16:54
  • If Firebug indicates that the POST operation is not occuring, then the PHP is not relevant. You need to do some debugging on the event handlers and form fields. Commented Jan 3, 2011 at 17:00
  • yeh i know, im so confused!!! thier might be something wrong with the plugin!!! Commented Jan 3, 2011 at 17:02
  • zurb.com/playground/ajax_upload can someone please look at this TUT for me!! Commented Jan 3, 2011 at 17:08

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

1

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

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

5 Comments

it is ok not sending header because some dumb browsers don't understand that and save the response as a download. In order to read the json use Jquery's parseJSON api.jquery.com/jQuery.parseJSON
@getaway — just use that as the first line of the PHP script.
@s3ven — which browsers will try to save a JSON response (with the correct content type) as a download if it is requested using XHR? … oh, this is going to be trying to deal with it using an iframe if there is a file upload, isn't it?
@david thanks david, i actually dnt think its the jason problem, this jquery is not sending the data to post, as shown on firebug!!
@David I just read that info somewhere, and it referred to some non-popular browsers. I don't know what's the deal with the iframe, I just understood that it's not good to send this header. For example: entwicklungsgedanken.de/2008/06/06/…

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.