views:

199

answers:

2

Hi, In my app i m using JQuery..In tat I m using tat Ajax GEt to retrive values from cakephp controller viewforms ....But if i alert myObject..It doesnt came..

It show me the error as missing ) in parenthetical {"attributes":[{"type":"Text","labels":"Untitled1"}]})

where {"attributes":[{"type":"Text","labels":"Untitled1"}]}) is my htm

THis is my JQuery code

                 $.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 + ')');

But the same code works well in other system.Please suggest me....

A: 

I am not familiar with PHP, but can you change you output type to make it text\json, and make sure that the ./viewForms doesn't include anyother php files that generates any HTML

bashmohandes
+1  A: 

Well, if your htm variable has an extra close parenthesis at the end, literally like so:

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

then that's your problem. Getting rid of the close parenthesis at the end forms a valid JSON string:

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

Perhaps if you shed some more light on the ./viewForms request handler (even give a code excerpt via pastebin) we could help more.

Roman Nurik
Ya now i removed the ) paranthesis and its working now.Thank U.
Aruna