Handling returned JSON data |
[eluser]CroNiX[/eluser]
Code: header('Content-type: application/json');
[eluser]dettie[/eluser]
It tries to return a plain text-file download when I use that. I'm using this Javascript btw: https://github.com/johnlanz/jquery-fileu...odeigniter
[eluser]Jason Stanley[/eluser]
Have you done the following to see what you actually have? Code: console.log(data); You can then view in Firebug or webkit web inspector what data actually contains. You may also want to investigate this function: http://api.jquery.com/jQuery.parseJSON/
[eluser]Aken[/eluser]
Yeah, your Javascript is probably interpreting the JSON string is a normal text string, and not as a JSON object.
[eluser]pictwist[/eluser]
Hello, Try to use Code: var d = jQuery.parseJSON(data);
[eluser]CroNiX[/eluser]
Whatever plugin you are using uses jquery ajax. Try setting the dataType: 'json', to tell it the expected returned result will be json. I use ajax/json all of the time with CI, so I know it works once it is set up properly.
[eluser]dettie[/eluser]
Thanks everyone for the replies/help I really appreciate it-- I don't believe the Jquery upload script used supports JSON return at all, check out the options: http://pixelcone.com/fileuploader/documentation/ I don't see a datatype or anything similar. I tried using jQuery.parseJSON(data); but that also does not seem to work.. I suppose I can try using another upload/ajax method if this one doesn't work out (any recommendations?)
[eluser]CroNiX[/eluser]
Try manually setting the global ajax config. Code: $.ajaxSetup({
[eluser]oursteps[/eluser]
I have the same problem as dettie. Code: $.ajax({ it returns "undefined". if I change Code: alert(data.url) Code: alert(data) Code: {"ajax":"1","url":"web url"} bug? the same on safari and firefox on Mac. |
Welcome Guest, Not a member yet? Register Sign In |