Hi all,
is there any javascript function or even in the jQuery Library (i suppose yes, because jQuery has JSON Library and is able to serialize) that does the same as PHP print_r()
function?
I've googled about this but I've found only functions to print mono-dimensional or bi-dimensional arrays.
thanks in advance...
José Moreira
EDIT:
Q: Why am I asking this?
A: Actually I have an $.ajax()
call that receives an JSON string like this (numbers are edited for privacy):
{"sms":{"92255221":{"status":true,"debug":"ok","warnmsg":"SMS Sended!"},"92255222":{"status":true,"debug":"ok","warnmsg":"SMS Sended!"},"92255223":{"status":true,"debug":"ok","warnmsg":"SMS Sended!"},"92255224":{"status":true,"debug":"ok","warnmsg":"SMS Sended!!"},"92255225":{"status":true,"debug":"ok","warnmsg":"SMS Sended!"},"92255226":{"status":true,"debug":"ok","warnmsg":"SMS Sended!"},"92255227":{"status":true,"debug":"ok","warnmsg":"SMS Sended!"},"92255228":{"status":true,"debug":"ok","warnmsg":"SMS Sended!"}}}
And on my success: function()
I've somethink like this:
success: function(response){
var data = $.parseJSON(response);
img_ok = "<img src=\"http://www.mysite.com/images/icons/icon-ok-16.png\" />";
img_fail = "<img src=\"http://www.mysite.com/images/icons/icon-fail-16.png\" />";
for (i=0;i<=mobilenumbers.length;i++){
var selector = "input.client[value*="+mobilenumbers[i]+"]";
// Remove input checkbox
$(selector).remove();
// Replace by an image
if(data['sms'][mobilenumbers[i]]['status']){
$(selector).filter(function(){return $(this).attr("checked");}).parent().append(img_ok);
}else{
$(selector).filter(function(){return $(this).attr("checked");}).parent().append(img_fail);
}*/
}
but firebug says that data['sms'][mobilenumbers[i]]
is undefined... but the strange thing is that the first data['sms'][mobilenumbers[i]]['status']
works fine!