jquery - AJAX call returning "Unexpected token <" -
jquery - AJAX call returning "Unexpected token <" -
so here's what's going on.
i've got ajax phone call that's supposed returning array of json objects.
the ajax phone call looks this:
ajax : function( url , data, success ){ homecoming $.ajax( { url : url, type : 'post', info : data, datatype : 'json', success : function( info ){ success( info ); }, error : function( jqxhr , textstatus , errorthrown ) { console.log( errorthrown ); } } ); }
the invocation of function this:
this.tvmodelsajax = this.ajax( sanus_website_search.tvmodelautocomplete, {q : autocompletecontroller.query }, autocompletecontroller.success );
and returned info looks this, if open in browser:
[{"name":"samsung 40\" 400bx","url":"\/app_dev.php\/en_us\/mountfinder\/samsung\/40%22\/400bx\/results\/"},{"name":"samsung 40\" 400cx","url":"\/app_dev.php\/en_us\/mountfinder\/samsung\/40%22\/400cx\/results\/"},{"name":"samsung 40\" 400cx1","url":"\/app_dev.php\/en_us\/mountfinder\/samsung\/40%22\/400cx1\/results\/"},{"name":"samsung 40\" 400cx2","url":"\/app_dev.php\/en_us\/mountfinder\/samsung\/40%22\/400cx2\/results\/"},{"name":"samsung 40\" 400cxn","url":"\/app_dev.php\/en_us\/mountfinder\/samsung\/40%22\/400cxn\/results\/"},{"name":"samsung 40\" 400cxn1","url":"\/app_dev.php\/en_us\/mountfinder\/samsung\/40%22\/400cxn1\/results\/"},{"name":"samsung 40\" 400cxn2","url":"\/app_dev.php\/en_us\/mountfinder\/samsung\/40%22\/400cxn2\/results\/"},{"name":"samsung 40\" 400dx","url":"\/app_dev.php\/en_us\/mountfinder\/samsung\/40%22\/400dx\/results\/"},{"name":"samsung 40\" 400dx2","url":"\/app_dev.php\/en_us\/mountfinder\/samsung\/40%22\/400dx2\/results\/"},{"name":"samsung 40\" 400dx3","url":"\/app_dev.php\/en_us\/mountfinder\/samsung\/40%22\/400dx3\/results\/"}]
but jquery throwing error telling me have unexpected "<" token somewhere...i'm @ loss.
any ideas?
folks,
seems php querying against expecting method, not post rest of calls on page. ended adding 'method' parameter ajax method. results below. help!
ajax : function( url , data, success, method = 'post' ){
homecoming $.ajax( { url : url, type : method, info : data, datatype : 'json', success : function( info ){ success( info ); }, error : function( jqxhr , textstatus , errorthrown ) { console.log( errorthrown ); } } ); }
jquery ajax json
Comments
Post a Comment