dpyic24480 2014-12-11 11:06
浏览 48

too long

I need some help with JSON and jquery.

I developing application with dhtmlx scheduler. I want to create dhtmlx sections dynamically.

I generating json_encoded string using php json_encode function given in following

["{key:23, label:'T23 (34)'}","{key:24, label:'T24 (34)'}","{key:26, label:'T26 (26)'}","{key:35, label:'T35 (25)'}"]

Ajax call function for this

$.ajax({
            url:"updatetablestr.php",
            type:"get",
            data:{id:id},
            dataType: 'json',
            beforeSend:function(){},
            success:function(q)
            {
            var JSONString = JSON.stringify(q);
            var output=JSONString.replace(/\"/g,"");                
            scheduler.updateCollection("MyList",output);
            }
            })

PHP function is,

$resarray=json_encode($array);
echo preg_replace('/"([a-zA-Z]+[a-zA-Z0-9_]*)":/', '$1:', $resarray);

i removed first and last quotes using jquery

var JSONString = JSON.stringify(q);
var output =JSONString.replace(/\"/g,"");

after this jquery code i could get my output

[{key:23, label:'T23 (34)'}","{key:24, label:'T24 (34)'}","{key:26, label:'T26 (26)'}","{key:35, label:'T35 (25)'}]

This output is what i need. when i use static code like

 var output= [{key:23, label:'T23 (34)'}","{key:24, label:'T24 (34)'}","{key:26, label:'T26 (26)'}","{key:35, label:'T35 (25)'}]

is working . When i implement dynamically which generated php , JSON.stringify is not working.. that time its showing the following error

scheduler.updateCollection("MyList",output);

"Uncaught TypeError: Function.prototype.apply: Arguments list has wrong type" in dhtmlxschduler.js

While statically working with same string why it's not working when dynamically generated using php and jquery..

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?
    • ¥15 matlab(相关搜索:紧聚焦)
    • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
    • ¥15 路易威登官网 里边的参数逆向
    • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
    • ¥50 需求一个up主付费课程