English 中文(简体)
Ajax 语法法 : 未发现语法错误: 未预料到的标识符
原标题:Ajax syntax : Uncaught SyntaxError: Unexpected identifier

I 正在得到这个未标记的语法错误: 意想不到的标识错误, 为什么?? 我觉得我使用语法错误得当吗? $. ajax ({p>: “loadent.php”, 数据 : { lastid: $($)($) post itit'). size (), 地点: $(# place” ). val (), rstatation: $("# rstatity"). val (), 性别: $("# gnder") 。 val () 成功: 函数(html) {uncaught} gmer: 未预期的标识, 如果 ($) {(# contentloadper). hide (; $(pre) (; =# contload.

最佳回答

您在 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) {
问题回答

您正在发送 jQuery 代码的字符串, 您正在错用逗号

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

与固定的,是固定的,

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

你似乎错过了一个逗号 介于你关闭的卷轴支架和成功之间:

“sccess” 之前缺少逗号





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签