admin管理员组

文章数量:1318572

I'm getting the following error: missing : after property id in line

data:{$("#msgForm").serialize() + "&field=msg_from"}

The code looks like the following:

$("#msg_from").autoplete({
  source:
    function (req, resp){
      $.ajax({
       url: "autopl.asp",
       data:{$("#msgForm").serialize() + "&field=msg_from"}
      });
    }
}); 

Any clue?

I'm getting the following error: missing : after property id in line

data:{$("#msgForm").serialize() + "&field=msg_from"}

The code looks like the following:

$("#msg_from").autoplete({
  source:
    function (req, resp){
      $.ajax({
       url: "autopl.asp",
       data:{$("#msgForm").serialize() + "&field=msg_from"}
      });
    }
}); 

Any clue?

Share Improve this question edited Jul 18, 2011 at 16:22 Naftali 146k41 gold badges247 silver badges304 bronze badges asked Jul 18, 2011 at 16:16 Magda MuskalaMagda Muskala 738 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 5

in your case it should be:

data: $("#msgForm").serialize() + "&field=msg_from"

in other cases, when using {}, you also need a key:

data: {'something': $("#msgForm").serialize() + "&field=msg_from"}

Remove the { and } from that line:

$("#msg_from").autoplete({
  source:
    function (req, resp){
      $.ajax({
       url: "autopl.asp",
       data: $("#msgForm").serialize() + "&field=msg_from"
      });
    }
});

The {} in data: {} is interpreted as object literal, not a code block (terminology?). Object literals are in the form { id: property }, hence the error message.

Your data should look like this:

data: $("#msgForm").serialize() + "&field=msg_from"

本文标签: javascriptError missingafter property idStack Overflow