Welcome to WebmasterWorld Guest from 54.159.189.139

Forum Moderators: open

Message Too Old, No Replies

Output received XML data to screen

Need to debug some ajax

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

Senior Member from US 

WebmasterWorld Senior Member 10+ Year Member

joined:Aug 28, 2002
posts: 994
votes: 2


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!
11:55 pm on Feb 7, 2013 (gmt 0)

Senior Member from US 

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

joined:Oct 17, 2005
posts: 4988
votes: 12


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) ;)
4:14 pm on Feb 8, 2013 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member 10+ Year Member

joined:Aug 28, 2002
posts: 994
votes: 2


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.
5:19 pm on Feb 8, 2013 (gmt 0)

Senior Member from US 

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

joined:Oct 17, 2005
posts: 4988
votes: 12


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);
2:49 pm on Feb 10, 2013 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:May 23, 2005
posts:742
votes: 0



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

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

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members