I'm trying to update the LastName field for PersonID. I can pass PersonID, but I don't know the syntax for also passing the LastName field.

$('input[name="LastName"]').live('focusout', function() {
    var PersonID = $(this).parents("tr").attr("ID");
    var LastName = $(this).val(); // todo: serialize

Q: Is is something like data:{'PersonID='+PersonID,'LastName='+LastName}

Am I missing a squiggly line or a parenthesis or comma or dot or colon or semi-colon or plus sign or question mark or an apostrophe or quote or dollar sign or something?

Was it helpful?


You're close! Change it just a little, no equals in there and use a colon like this:

data: {'PersonID':PersonID, 'LastName':LastName}

You can also do this if you prefer (not as safe if you get some weird characters though)

data: 'PersonID=' + PersonID + '&LastName=' + LastName


For complicated structures in case you add more then 2 vars:

var obj = new Object;
obj.something1 = 'something';
obj.something2 = Array();
obj.something2[1] = 'foo';
obj.something2[2] = 'bar';

//include json2.js
var objJSON =  JSON.stringify(obj);

      url: "",
      type: "GET",
      data: ({obj: objJSON , method : "UpdateLastName"}),
      contentType: "application/json; charset=utf-8",
      dataType: "html",
      success: function(msg){
         alert("Success: " + msg);
      error: function(msg){
         alert("Error: " + msg);

On cf side just do

<cfset test = deserializeJSON(arguments.obj,true) >
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow