2009-06-10 51 views
0

在我的应用程序使用的IM达JQuery..In我为使用达阿贾克斯获得以检索从CakePHP的控制器viewforms值....但是,如果我警报myObject..It犯规来..阿贾克斯获得+ JQuery的

这表明我的错误作为 missing) in parenthetical {"attributes":[{"type":"Text","labels":"Untitled1"}]})

其中{"attributes":[{"type":"Text","labels":"Untitled1"}]})是我的HTM

这是我的jQuery代码

$.ajax({ 
    type: "POST", 
    url: "./updateField", 
    data: "name=" + fieldname, 
    success: function(msg){ 
    }//success 
});//ajax 

//Retriving the updated value in JSON Format 
var htm = $.ajax({ 
    type: "GET", 
    url: "./viewforms", 
    async: false 
}).responseText; 

var myObject = eval('(' + htm + ')'); 

而T3他相同的代码在其他系统中运行良好。请建议我....

+0

请向我们展示更新“内容”的代码。 – 2009-06-10 05:45:56

+0

已经阅读过好几次,但问题还不清楚。你能解释更多吗? – 2009-06-10 06:03:06

回答

1

好吧,如果你htm变量在最后一个额外的右括号,从字面上像这样:

{"attributes":[{"type":"Text","labels":"Untitled1"}]}) /* extra close paren */ 

那么这是你的问题。摆脱在最后的右括号形成一个有效的JSON字符串:

{"attributes":[{"type":"Text","labels":"Untitled1"}]} /* no close paren */ 

或许,如果你洒在./viewForms请求处理一些比较轻(甚至给通过引擎收录代码摘录)我们可以帮助更多。

0

我不熟悉PHP,但是你可以改变你的输出类型使其成为text \ json,并确保./viewForms不包含任何其他的php文件, HTML