Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm constantly getting this error in safari but google chrome doesn't show any such error. As far as I know my syntax is correct. Any lead what possible I am doing wrong ?
i have mentioned the error like code with the error in the code below

What I have tried:

function submit_quiz_answers() {

            $.ajax({
                type: "POST",
                cache: false,
                url: "save_quiz_answers.php?",
                dataType: 'JSON',
                data: {answered_array},
questions.php:256SyntaxError: Expected an identifier but found '}' instead
                success: function (Rdata) {
                    if (Rdata == 1) {

                        swal("Thank You", "For participating in the quiz.", "success");

                        setTimeout(function () {
                            pageRedirect();
                        }, 1000);

                    } else {
                        alert("error");
                    }
                },
                error: function (e) {
                }
            });
        }
Posted
Updated 27-Oct-20 6:26am
Comments
Sandeep Mewara 23-Oct-20 10:22am    
Easiest would be to DEBUG in safari to nail it down.

Not sure, could be what and how you are passing 'data'. What does answered_array translates to ?
ZurdoDev 23-Oct-20 11:47am    
data: {answered_array},
seems to be the issue.

1 solution

Quote:
JavaScript
data: {answered_array}
According to MDN, shorthand property names work in Safari 9 or later. Version 9 was released in September 2015. If you're running an older version on Mac or iOS, then you are dangerously out of date.

NB: The last version of Safari released for Windows was v5.1.7 from May 2012. If you're using that, then you might as well assume that your system has been completely compromised.

If you absolutely need to support older browsers - for example, Internet Explorer - you'll need to use the full object syntax:
JavaScript
data: { answered_array: answered_array }
Object initializer - JavaScript | MDN[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900