Asynchronous call doesn't return json
I am running wamp on an xp box. I am fairly new to web programming, this is for a student project, and have run out of avenues to try to solve this problem.
Problem
We have client side JavaScript code that uses GDownloadUrl- from the Google api- to wrap xmlHttpRequest calls to a php server side program that is accessing our database. In my callback program, the result of this call is always " ".
However, if I use an alert to display the http:// call, with the arguments, and cut and paste that into my browser, the json I expected is displayed. I zipped my dir containing all the files, and tried it out on another team member's computer, and they were able to get the json in the callback function. Note this is exactly the same code and structure I was using, he just unzipped and ran.
So now I'm thinking开发者_运维知识库 this is something about Firefox or Wamp? Would this be a config problem? I'm running wamp server 2.0, and Firefox 3.5.8.
I have no problems with synchronous php, or reading in files asynchronously. Any help would be greatly appreciated.
Rebecca
Since you're using FireFox, try installing:
HTTPFox - when activated keeps a log of all outgoing requests and the server responses and all headers. If there's something about your FireFox that's munging the AJAX calls, you would be able to see the request go out and whatever the server's response is.
FireBug - a complete DOM/JavaScript/CSS analyser/debugger. If something goofy is going on, you'll be able to see the script's actions on the DOM as it works.
And of course, just hit CTRL-J to pop up the JavaScript console, which will log any errors encountered.
That takes care of the client side. Server-side, I'd suggest slapping some debug code into the PHP script in the AJAX handlers. Dump the _GET/_POST arrays to a log and see what the request looks like when (if?) it comes in from your client. Log the generated JSON data before it's dumped to the client - if it's coming out blank on the server, then you'll know it's not your browser mis-interpreting the response.
精彩评论