0

this code here is suppose to call a file that will in return return data for fill in a form but i am getting this error (in the code) and i do not know why.

dropdown.bind('change', function(){
    $post.('backgroundScript.php', 
Uncaught SyntaxError: Unexpected token ( - this is the error im getting
        { 
            first: dropdown.val() 
        },
        function(response) {
            $('#first').val(response.first);
            $('#last').val(response.last);
            // Repeat for all of your form fields
        },
        'json'
    );
});

it you would give me a hand i would appreciate it :)

2 Answers 2

3

Put the . before post instead of after it, thx to Mihai Stancu for spotting that.

dropdown.bind('change', function(){
    $.post('backgroundScript.php', 
        { 
            first: dropdown.val() 
        },
        function(response) {
            $('#first').val(response.first);
            $('#last').val(response.last);
            // Repeat for all of your form fields
        },
        'json'
    );
});
Sign up to request clarification or add additional context in comments.

3 Comments

$post is not going to work either, It's going to show another error regarding $post as an undefined variable and not a function. The jQuery object is aliased as $ so accessing a method on the jQuery object looks something like this jQuery.post() or $.post().
that might be true, but it will solve your syntax error, if $post isn't defined then you will have to look into why that is.
$.post is a method of the jQuery object which he seems to be using (due to the order and type of parameters specified to the function itself).
0

Try using "$.post( instead of $post.(

4 Comments

The jQuery object is aliased as $ so accessing a method on the jQuery object looks something like this jQuery.post() or $.post()
@A.K OP did not mention jQuery, it's natural that JavaScript devs that do not know jQuery reach this page and try to answer as best they can. At this point we can only assume it was jQuery due to the look and feel of the parameters given to the $.post function. We may be wrong it may be some other framework.
He also didn't mentioned ajax. And in simple javascript $ has no meaning.
Yes it does, it can be a variable name ;-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.