Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery doesn't work on my server but does work in jsfiddle [closed]

Tags:

jquery

This is starting to freak my out by now. What's happening here?

See no result on http://www.mauricekappelhof.nl/work/TemplateTest/Backend/menu.php?page=1 See working result on http://jsfiddle.net/x7bgF/

Oh, i want to replace spaces with an underscore. So if you type a space in the 'Titel' field, the 'link' field suppose to show the same, but then with an underscore.

It's about this piece of jQuery

 $(document).ready(function(){
        $('#title').keyup(function(e){
            var e = e || window.event;
            $('#link').val($(this).val().replace(/\s/g, '_'));
        });​
    });
like image 660
Maurice Avatar asked Oct 24 '12 13:10

Maurice


2 Answers

You have an illegal character

$(document).ready(function(){
    $('#title').keyup(function(e){
        var e = e || window.event;
        $('#link').val($(this).val().replace(/\s/g, '_'));
    });? // <--  delete this and rewrite it
});

You can see it in notepad++

It's from copy and pasting from jsfiddle

like image 72
wirey00 Avatar answered Nov 15 '22 07:11

wirey00


I get:

SyntaxError: illegal character

});?

menu.php?page=1 (line 50, col 5)

on my log (note that the ? isnt displayed on my firebug, seems there is a hidden character or something on your php file).

when you change encoding on the source code you will get:

$(document).ready(function(){
    $('#title').keyup(function(e){
        var e = e || window.event;
        $('#link').val($(this).val().replace(/\s/g, '_'));
    });​
});

you may want to change your php file to UTF-8 if you are using that as encoding, firefox says you are using ISO-8859-1

like image 26
voigtan Avatar answered Nov 15 '22 08:11

voigtan