Uncaught SyntaxError: Unexpected token :

yorin

i have an unexpected token : but i dont know why this is.

the code where it is happening.

<script type="text/javascript">
$('.delete-btn').click(function() {
 $.ajax(function() {
    type: 'POST',
    url: 'ajax.php',
    data: { filename: filename },
    success: function(return) {
        if(return == 'SUCCESS') {
            $this = $(this).closest('tr');
            $this.remove();
        }
    }
});
});
</script>

I hope someone can find why i get the unexpeded token : at the url: 'ajax.php', rule.

James Allardice

The syntax error is in your success callback. You've named the argument return, which is a reserved word. Call it something else.


Niet here, merging my answer into this one to complete the picture:

Change:

$.ajax(function() {

To:

$.ajax({

Pay closer attention to what you're writing :p

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

TOP Ranking

HotTag

Archive