I have AJAX requests from which I get a JSON-format response, which is being attended to and everything works well.
The problem is when the application-level debug is on, some more info like SQL statements are outputted along with JSON and the things don't work.
Question: Is there开发者_如何学Go a ways to selectively pick contents from the AJAX response, so that the response works regardless of whatever comes along with it.
I use jQuery.
No.
Make it so that your server-side application doesn't produce this malformed output.
This is why outputting debug to the main output is bad. You should be outputting to some internal logfile on the server that doesn't affect the business output.
If desperate, you could have the debug messages injected into the JSON.
no. you can't just parse json code with another mess/garbage. If you have FIXED value of that json, you can make substring from it.
精彩评论