Take the 2-minute tour ×

Hy everybody!

I try to send files via jQuery.ajax, and the posting is works nicely. After the saving of file is done, try to send back a json object of the database information.

like that:

echo json_encode($DatabaseEntity);

But client-side the ajax success callback's "data" parameter is null, instead of a json object.

jQuery.ajax is set up like this:

    url: /* url */,
    type: "POST",
    data: postingData, // it's a FormData object
    dataType: "json",
    cache: false,
    contentType: false, // it's because the FormData, if I set "multipart/form-data", then the data not sended
    processData: false,                                
    success: function(data) {
        alert(data); // => this is NULL, and I don't know why!

Firefox FireBug shows the result: that's a well formated json string

Have any ideas why "data" is null?


$DatabaseEntity contains something like that:

object(DatabaseEntity)#15 (9) {
   string(5) "somethinglabel"
   string(3) "somethingdesc"
   string(6) "somethinglink"
   string(4) "1761"
   string(1) "1"
   string(1) "1"
   string(1) "1"
share|improve this question
Because $DatabaseEntity is null from the serverside itself ..try to print it on the server side before the json_encode function and see whats in it –  ubercooluk Oct 3 '12 at 10:39
it's not null, it's an object –  SadAir Oct 3 '12 at 10:50
$DatabaseEntity is array ? can you specify $DatabaseEntity –  Man Programmer Oct 3 '12 at 11:13
I'm updating the question with the $DatabaseEntity spec. I hope it's useful.. –  SadAir Oct 3 '12 at 11:40
add comment

2 Answers

echo json_encode("Values"=>$DatabaseEntity);

share|improve this answer
unfortunately does't work.. –  SadAir Oct 3 '12 at 11:10
add comment

If you are returning just one string, use the .d attribute

share|improve this answer
i'm returning an object, but data is null so data.d also null –  SadAir Oct 3 '12 at 11:08
add comment

Your Answer


