Reputation: 990
I have the following script, which returns me the following error in my console:
Uncaught SyntaxError: Unexpected token }..
The }
in between **
is the one causing the problem according to my console. But that's the bracket which closes the 'success' of the AJAX request.. And also if i remove the statement pointed out with the -> the error seems to disappear. Does someone see what is wrong about this?
Note: I don't have those **
in my code, that's just for pointing out the error.
$(document).ready(function() {
$('#edit_patient_info').click(function () {
//Get the data from all the fields
$.ajax({
url: "patient_info_controller.php",
type: "POST",
data: data,
success: function (msg) {
if (msg==1) {
getPersoonlijkGegevens(user_id);
unLockFirstPage();
alert("Gegevens zijn gewijzigd!");
$("#searchbox").val(voornaam.val());
searchPatient();
-> $('#selectable li:first').addClass('ui-selected');
}
**}**
});
});
});
Upvotes: 0
Views: 1228
Reputation: 1633
You had an extra }
$(document).ready(function() {
$('#edit_patient_info').click(function() {
//Get the data from all the fields
$.ajax({
url: "patient_info_controller.php",
type: "POST",
data: data,
success: function(msg) {
if (msg == 1) {
getPersoonlijkGegevens(user_id);
unLockFirstPage();
alert("Gegevens zijn gewijzigd!");
$("#searchbox").val(voornaam.val());
}
}
});
});
});
Upvotes: 0
Reputation: 72957
You had a hidden character after $('#selectable li:first').addClass('ui-selected');
That invalidated your code. Usually, these can be seen when you copy your code to notepad (Or notepad++).
In notepad++, it displayed .addClass('ui-selected');?
Also, you had a extra }
.
Try this:
$(document).ready(function() {
$('#edit_patient_info').click(function () {
//Get the data from all the fields
$.ajax({
url: "patient_info_controller.php",
type: "POST",
data: data,
success: function (msg) {
if (msg==1) {
getPersoonlijkGegevens(user_id);
unLockFirstPage();
alert("Gegevens zijn gewijzigd!");
$("#searchbox").val(voornaam.val());
searchPatient();
$('#selectable li:first').addClass('ui-selected');
}
}
});
});
});
Upvotes: 4
Reputation: 38345
From what I can tell it's actually the }
two lines down from the one you've marked that's causing the issues; it doesn't match up with any of the opening {
characters.
Upvotes: 1