Archived from the Transloadit support forum. Originally posted on March 1, 2011; details may be outdated, see our docs for current behavior. Original thread
It seems like I’m not getting back and array, but instead a string in some cases. Just my php_decode not working right?
Example…
44adacf7…
So I get $results[ is a really long string containing "[{“id…]” what seems like should be valid json.
Any help would be appreciated,
Jeff
Are you using the PHP sdk? What’s php_decode? Do you mean json_decode?
I’m not using the SDK. just, json_decode($transloadParams, true) . Likely something with my code, I just haven’t figured it out yet and thought I should ask.
Our service always sends back valid JSON. So if you can’t parse it, it might be a problem on your end. Maybe magic quotes?
but actually from the raw response in chrome it seems like it is being returned as a string in this case, idk…
Well, chrome will render all JSON as a string by default (afaik). You can install an extension for that:
https://chrome.google.com/extensions/detail/ddngkjbldiejbheifcmnfmmfiniimbbg?hl=en
So I’ve taken a look at this too (I work with Jeff) and your right, your service is responding with totally fine JSON in the assembly polling callback (when it reaches ASSEMBLY_COMPLETED).
What seems strange then is when the jQuery plugin then submits the form the “uploads” key gets “stringified” and the double quotes get slash-escaped from the version your service returns. So, this might be something that’s happening in the jQuery plugin, and possibly the result of a conflict with other Javascript on our page.
I’m going to try setting autoSubmit to false and inspect the state of the form/jQuery plugin after the poll is finished, other than that do you have any ideas?
Felix,
Thanks for your help. I figured out that it was a conflict with prototype.js in some cases. It was working 100% in my test bed, even using jQuery noConflict (since we have prototype on all pages). But for some reason the same technique in an iframe was giving the bad result. Removing prototype.js from my iframe makes it work great!
Just wanted to pass along my experience for anyone else with similar setup.
(ok, I’m trying to get rid of prototype.js dep =)
Hi Jeff,
glad you were able to figure it out. If there is anything we could do on our end to avoid conflicts like this, we’re also willing to change.
But yeah, throwing prototype out seems like the nicer solution : ).
--fg
Felix,
I think you guys have done a great job already. Just having this thread on record, might help others in my situation. Or maybe if its common enough include it in the faq or something.
Thanks again for your hard work, and I’m looking forward to rolling out your service to our users!
I think you guys have done a great job already. Just having this thread on record, might help others in my situation. Or maybe if its common enough include it in the faq or something.
I think tender should pop it up, when somebody opens a new ticket describing a similar issue.
Let me know if you have any other questions, we’re here to help!