大家好,
有任何的JavaScript功能,甚至在jQuery库(我想是的,因为jQuery有JSON库并能够序列),做同样的PHPprint_r()
功能?是否有任何JavaScript函数,或者甚至在与PHP print_r()相同的jQuery库上?
我一派这个,但我发现只有函数来打印单维或双维数组。
在此先感谢...
何塞·莫雷拉
编辑:
问:我为什么问这个?
答:其实我有一个$.ajax()
呼叫接收的JSON字符串像这样(数字编辑隐私):
{"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!"}}}
而且我success: function()
我已经somethink这样的:
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);
}*/
}
但萤火虫说data['sms'][mobilenumbers[i]]
是未定义的......但奇怪的是,第一个data['sms'][mobilenumbers[i]]['status']
工作正常!
你的bug在这里我<= mobilenumbers.length;索引从0开始,你试图阅读太多的索引。你的代码也是非常低效的,因为你继续查找你已经查找过的东西一次。你是我的全球。当选择器可以做到这一点时,为什么在过滤器中使用函数? – epascarello 2010-07-10 14:46:45
@epascarello我试过了:在我的选择器上检查过,但没有奏效,不问我为什么...该呼叫是给错误,现在纠正,但没有成功 – CuSS 2010-07-10 15:06:16
@ALL 问题解决了,PHP返回坏数字,错误到'array_merge_recursive()'功能... 感谢所有 – CuSS 2010-07-10 15:38:29