This topic contains 4 replies, has 2 voices, and was last updated by infocurci 9 years, 3 months ago.
- Topic
Hello,
I need of execute an Ajax code on my bundle.
I created my REST function (on Controller/Api/Rest) and it works fine, I tested on app_dev.php/api/doc.
I tried to call my function on my view, in this mode:1234567891011121314151617$.ajax({type: "GET",url: (my url.json, copied from app_dev.php/api/doc)beforeSend:function(xhr){xhr.setRequestHeader('X-CSRF-Header', '1');},cache: false,success: function(data, textStatus){risultato_ajax = $.parseJSON(data);alert(risultato_ajax.label);},async: false});The function works fine and return this string:
123[{"label":"teams"}]but on my console I found this error:
Error: SyntaxError: JSON.parse: unexpected character at line 1 column 2 of the JSON data
There is, on your code, an example to implement correctly an Ajax call?
Thanks!!!
The forum ‘OroPlatform – Programming Questions’ is closed to new topics and replies.