Welcome to WebmasterWorld Guest from 54.147.0.174

Forum Moderators: open

Message Too Old, No Replies

Output received XML data to screen

Need to debug some ajax

     

Philosopher

10:29 pm on Feb 7, 2013 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I had some code written for me (I'm not well versed with js and ajax) that posts data from a form and receives an xml response.

I'm having some issues and need to do a bit of debugging. To do that I need to see what is actually being received but since I've never been very handy with js much less ajax, I could use some help.

Here is the pertinent code below:


$.ajax({
type: "POST",
timeout:120000,
url: urltxt,
async: true,
data:tdata,
beforeSend: function() { $.mobile.showPageLoadingMsg("c","Processing...",false);
}, //Show spinner
complete: function() { $.mobile.hidePageLoadingMsg()
}, //Hide spinner


success: function(msg){
error = "";
$(msg).find('response').each(function(){

lots of code to test various responses...
});

Any help would be greatly appreciated!

Fotiman

11:55 pm on Feb 7, 2013 (gmt 0)

WebmasterWorld Senior Member fotiman is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



success: function(msg){
...
}

That is your success handler... the result of your POST. msg contains the data returned, so you could inspect that to see what was actually received. Most browsers today include developer tools that allow you to set breakpoints and inspect data at runtime. For example, in Chrome you can press F12 to open the Developer Tools, then find that line in the code and add a breakpoint. Then add the msg to the watch list.

Alternatively, you could do something like alert(msg) ;)

Philosopher

4:14 pm on Feb 8, 2013 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Unfortunately, this script is part of an mobile app built with some phonegap, etc. so I can't use the dev tools available in FF or Chrome to inspect the received data.

I need to to include some code to print it to the screen itself.

I tried using commenting out everything after

success: function(msg){ to the closing brace and adding "alert(msg);", but got nothing.

Any other options would be appreciated. I'm definitely out of my comfort zone in js and ajax.

Fotiman

5:19 pm on Feb 8, 2013 (gmt 0)

WebmasterWorld Senior Member fotiman is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



When you say you "got nothing", does that mean you didn't even see an alert dialog? If so, that would suggest that your success handler was never reached.

I assume that the msg contains an XML document, which contains 1 or more <response> elements. Perhaps you could do something like:

$('body').append("<textarea id='debugOutput' rows='10' cols='30'><\/textarea>");
$('#debugOutput').val(msg);

drhowarddrfine

2:49 pm on Feb 10, 2013 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




...I can't use the dev tools available in FF or Chrome to inspect the received data.

Yes you can. [developers.google.com...]
 

Featured Threads

Hot Threads This Week

Hot Threads This Month