3

I am getting this Uncaught SyntaxError: Unexpected identifier error , Why ? I think i have used the syntax properly ?

$.ajax({
    url: "loadcontent1.php",
    data: {
        lastid: '$(".postitem").size()',
        location: '$("#location").val()',
        rstatus: '$("#rstatus").val()',
        gender: '$("#gender").val()'
    }
    success: function(html) {
        Uncaught SyntaxError: Unexpected identifier
        if (html) {
            $("#contentwrapper").append(html);
            $('div#ajaxloader').hide();

            $("#contentwrapper").masonry('reload');
            FB.XFBML.parse();

        } else {
            $('div#ajaxloader').html('<center>No more Images.</center>');
        }

    }
});​
2
  • 1
    As an aside, are you sure you want quotes around $(".postitem").size() ? Commented May 24, 2012 at 16:40
  • There is no such thing as "Ajax syntax". Commented May 24, 2012 at 16:47

4 Answers 4

14

You left off the comma after the data

$.ajax({
    url: "loadcontent1.php",
    data: {
        lastid: $(".postitem").size(),
        location: $("#location").val(),
        rstatus: $("#rstatus").val(),
        gender: $("#gender").val() // not strings!
    }//, comma here!
    success: function(html) {
Sign up to request clarification or add additional context in comments.

Comments

2

You are sending up strings with the jQuery code and you are mising a comma

data: {
    lastid: '$(".postitem").size()',  <--no single quotes
    location: '$("#location").val()', <--no single quotes
    rstatus: '$("#rstatus").val()', <--no single quotes
    gender: '$("#gender").val()' <--no single quotes
}  <--no comma

with it fixed it should be

data: {
    lastid: $(".postitem").size(), 
    location: $("#location").val(),
    rstatus: $("#rstatus").val(),
    gender: $("#gender").val() 
},

Comments

2

You seem to be missing a comma between your closing curly brace and success:.

Comments

1

A comma is missing before "success"

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.