Quantcast
Channel: Adobe Community : All Content - ColdFusion
Viewing all articles
Browse latest Browse all 5979

'Unexpected token /' in response using SerializeJSON() with jQuery .ajax()

$
0
0

Hello CF folk, I hope you can help.

 

I'm using jQuery .ajax to post a javascript array to a CF page, which queries a database table and returns a serialized result.  In the 'Network' tab of Developer Tools the result looks good and

contains expected data, however it gives an error message "Syntax error :Unexpected token: /".   The response is prefixed by two slashes as below.

 

 

//{"COLUMNS":["Field1","Field2","Field3","Field4"],"DATA":[[1,0,162,"text1"],[2,0,162,"tex t2"],[3,0,704,"text3"],[4,0,705,"text4"],[5,0,127,"text5"],[6,0,0,""]]}

 

 

The .ajax request is below:

 

  $.ajax({

       type: "POST",

       dataType: "json",

       url:  "/links.cfm",

       data: {"images" : JSON.stringify(thumbnails_array)},

       error: function(xhr, textStatus, errorThrown){

            alert("An error occurred: " + errorThrown);

       },

       success: function( data ) {

            alert("Reached success stage");

            $.each(data, function(key) {

            console.log(data[key][1]);

            if (data[key][1] !== 0) {

                 ---use this element---;

            }

            });

         }

  });

 

 

I'm assuming this // prefix is the unexpected token, how do I remove/resolve it?  In the called page 'links.cfm' I'm using SerializeJSON() on the query result to create the response.

 

Any help much appreciated,

 

Many thanks,


Viewing all articles
Browse latest Browse all 5979

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>