'Where is the syntax error located in this JavaScript code? [closed]
I have a syntax problem somewhere but can't spot it as I am not a javascript developer. Can someone with a better eye point out the problem?
$.ajax(
{
type: 'GET',
url: / + 'modules/blocklayered/blocklayered-ajax-back.php',
Uncaught SyntaxError: Unexpected token ILLEGAL
data: (all ? '' : $('input[name="categoryBox[]"]').serialize()+'&')+(id_layered_filter ? 'id_layered_filter='+parseInt(id_layered_filter)+'' : ''),
success: function(result) {
Solution 1:[1]
The syntax error is on this line...
url: / + 'modules/blocklayered/blocklayered-ajax-back.php',
The / is misplaced, and should be...
url: '/modules/blocklayered/blocklayered-ajax-back.php',
Solution 2:[2]
You have a typo in your url: parameter:
$.ajax({
type: 'GET',
url: / + 'modules/blocklayered/blocklayered-ajax-back.php',
// ^^ here
data: (all ? '' : $('input[name="categoryBox[]"]').serialize()+'&')+(id_layered_filter ? 'id_layered_filter='+parseInt(id_layered_filter)+'' : ''),
success: function(result) {
The correct code should be:
$.ajax({
type: 'GET',
url: '/modules/blocklayered/blocklayered-ajax-back.php',
data: (all ? '' : $('input[name="categoryBox[]"]').serialize()+'&')+(id_layered_filter ? 'id_layered_filter='+parseInt(id_layered_filter)+'' : ''),
success: function(result) {
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | freefaller |
| Solution 2 | BenM |
