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>');
}
}
});
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>');
}
}
});
Share
Improve this question
edited May 24, 2012 at 16:46
Felix Kling
816k180 gold badges1.1k silver badges1.2k bronze badges
asked May 24, 2012 at 16:36
YahooYahoo
4,18718 gold badges64 silver badges85 bronze badges
2
|
4 Answers
Reset to default 14You 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) {
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()
},
You seem to be missing a comma between your closing curly brace and success:.
A comma is missing before "success"
$(".postitem").size()
? – Denys Séguret Commented May 24, 2012 at 16:40