bravo14 Posted December 13, 2017 Share Posted December 13, 2017 Hi I am using the javascript below to carry put an ajax call. $('#tokenfield') .on('tokenfield:createdtoken', function (e) { $.ajax({ url: 'processProduct.php?action=addTag', type: 'post', data: {tag:e.attrs.value ,photo:83}, }); }); .tokenfield({ autocomplete: { source: function (request, response) { jQuery.get("processProduct.php?action=getTags", { query: request.term }, function (data) { data = $.parseJSON(data); response(data); }); }, delay: 100 }, showAutocompleteOnFocus: true }); When the page loads I get the following error in the console yntaxError: expected expression, got '.'[Learn More]index.php:416 the unexpected '.' is the following line .tokenfield({ I am sure that the answer is really simple, but I can't figure it out at the moment, any hepp would be fantastic Quote Link to comment https://forums.phpfreaks.com/topic/305908-expected-expression-got/ Share on other sites More sharing options...
gizmola Posted December 13, 2017 Share Posted December 13, 2017 Do you think that '.tokenfield({' is valid javascript syntax? I also don't know why you are showing us a php error? Is this javascript inside a php file? Also don't see why you are mixing the use of $ and jQuery... At any rate, this is certainly more likely to be valid javascript... $('#tokenfield').on('tokenfield:createdtoken', function (e) { $.ajax({ url: 'processProduct.php?action=addTag', type: 'post', data: {tag:e.attrs.value ,photo:83}, }); }); $('#tokenfield').autocomplete({ source: function (request, response) { jQuery.get("processProduct.php?action=getTags", { query: request.term }, function (data) { data = $.parseJSON(data); response(data); }); }, delay: 100 }, showAutocompleteOnFocus: true }); Quote Link to comment https://forums.phpfreaks.com/topic/305908-expected-expression-got/#findComment-1554663 Share on other sites More sharing options...
denno020 Posted December 13, 2017 Share Posted December 13, 2017 There are issues with your code, no doubt, but what our friend above didn't mention is the reason you're getting the error is because you've got a semi colon at the end of line 8, even though you then try and concatenate another function call. Remove that semi colon and your code shouldn't complain. Whether it works as you expect it to is what you'll need to test next Denno Quote Link to comment https://forums.phpfreaks.com/topic/305908-expected-expression-got/#findComment-1554665 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.