5

I have created a php page that displays some records from my db.
I also have a button that executes some ajax to update the records, and then show the new / updated dataset on the same page. I'm having problems with my ajax call and I'd like some tips on how to troubleshoot. I've noticed that since my header has been explicitly set to be json content, i can't just do things like var_dump from the controller to see the data BEFORE it is sent to the view. Unfortunately, for some reason, my console.log calls in the ajax method are not working for me either. i don't know why.

But I'm wondering if someone can tell me other ways to debug my code. I know I can change the json data type to html / text and then remove all code in my controller that sets headers / calls json_encode... but just in case there's a better way, I thought I'd ask.

1
  • F12 - check the direct output in network tab if you're using chrome. Most likely other browsers have similar functionality. Commented Dec 17, 2012 at 18:39

2 Answers 2

5

You can use the Developer console in Chrome, click on the Network tab, and then at the bottom you can limit the type to "XHR" then you can try to make the AJAX request, and you should see everything there is to see about it, including the response, etc.

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

Comments

0

Chrome has some great tools (as in another answer) in addition to extensions like JSONView

I wrote a simple tool to help debug Web services independent of how your app calls it. Save that page as HTML to your local dev site, enter the URL of your Web service, select the HTTP method and click the "send request" button. Hopefully it will give you what you need.

Comments

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.