Question

I get this error: First error: Uncaught SyntaxError: Unexpected token } => jquery-1.9.1.min.js:3 Now the error says: Uncaught SyntaxError: Unexpected token } =>fase1_manual.php?lic=1:15

But when i look where they say, I don't see any error...

On my page, the only jquery i use is:

<script type="text/javascript">
    $(document).ready(function () {
        $('#mydate').click(function() {
            $('#mydate').datebox('open');
        });
    });
</script>

And i use a jQuery Mobile datebox.

Can't seem to see what's wrong, makes my page freeze from time to time, when submitting my form. Thanks to anyone that can help!

Entire page:

<?php
session_start();
include("connections.php");

$nameErr = $fnameErr = $bdErr = "";
$name = $fname = $bday = "";
if (isset($_GET["submit"]) && !empty($_GET['submit'])) 
{
    if (empty($_GET["patname"])) {
        $nameErr = "Mag niet leeg zijn";
    }
    else {
        $name = cleanValue($_GET["patname"]);
        if(preg_match("/^[a-zA-Z -]+$/",$name))
        {
            $nameErr ="";
        }
        else 
        {
            $nameErr = "Moet enkel uit letters bestaan";
        }
    }

    if (empty($_GET["patfname"])) {
        $fnameErr = "Mag niet leeg zijn";
    }
    else {
        $fname = cleanValue($_GET["patfname"]);
        if(preg_match("/^[a-zA-Z -]+$/",$fname))
        {
            $fnameErr="";
        }
        else
        {
            $fnameErr = "Moet enkel uit letters bestaan";
        }
    }
    if (empty($_GET["birthdate"])) {
        $bdErr = "Mag niet leeg zijn";
    }
    else {
        $bday = cleanValue($_GET["birthdate"]);
        $bdErr="";
    }

    if ( $fnameErr === '' &&  $nameErr === '' && $bdErr === '') {
        $destination_url = "fase1.php?patfname=$fname&patname=$name&birthdate=$bday&lic=".$_SESSION['lic_key'];
        header("Location:$destination_url");
        exit();
    }
}

include("header.php");
?>

<div id="div-header-fullwidth">
    <p>MediQueue Registratie APP: FASE 1 - Zelfregistratie</p>
</div>
<div id="div-content-fullwidth">
    <div id="div-container">
        <div id="div-logo">
            <p>
                <img src="http://mediqueue.newworld02.be/iris/registration/img/logo.png" width="129" height="158" id="logo" alt="logo" />
            </p>
        </div>
        <div id="div-form">
            <form id="test" method="get" action="<?php echo $_SERVER['PHP_SELF'];?>">
                <table>
                    <tr>
                        <td>
                            <label for="patfname" class="ui-input-text">Voornaam:</label>
                        </td>
                        <td>
                            <input type="text" id="patfname" name="patfname" value="<?=$fname?>"/>
                        </td>
                        <td class="error">
                            <?php echo $fnameErr;?>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <label for="patname" class="ui-input-text">Achternaam:</label>
                        </td>
                        <td>
                            <input type="text" id="patname" name="patname" value="<?=$name?>"/>
                        </td>
                        <td class="error">
                            <?php echo $nameErr;?>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <label for="mydate" class="ui-input-text">Geboortedatum:</label>
                        </td>
                        <td>
                            <input name="birthdate" id="mydate" value="<?=$bday?>" data-role="datebox" data-options='{"mode": "datebox", "beforeToday": true, "minYear": 1900, "overrideDateFieldOrder": ["d","m","y"], "overrideDateFormat": "%Y-%m-%d", "lockInput": true, "centerHoriz": true}' readonly="readonly"/>
                        </td>
                        <td class="error">
                            <?php echo $bdErr;?>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <input type="submit" name="submit" value="Registreer" data-theme="a"/>
                        </td>
                    </tr>
                </table>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        $('#mydate').click(function() {
            $('#mydate').datebox('open');
        });
    });
</script>
<?
include("footer.php");
?>
Was it helpful?

Solution

I think it was a bug in jQuery Mobile, we decided to change everything to bootstrap, so only css-wise things changed, javascript/php/html stayed the same and the bug dissapeared.

OTHER TIPS

Try running your javascript code in jslint http://www.jslint.com/ and you will find the catch.

If you still face the issue, try using google jquery from link https://developers.google.com/speed/libraries/devguide
to make sure that problem with jquery only.

If it works fine, then you need to reload jquery again, it may be the problem that jquery file was not downloaded correctly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top