jQuery ajax callback not firing jQuery code.

I have a checkbox on a webpage that when you click it, updates the value in the database as well as the editedBy and editedDate columns in a table in the database. I am doing the update via an ajax call to a php page. I am trying to get the updated editedDate and editedBy data in the callback on success so i can update the sorresponding span tags that hold this information. I'm trying to use jQuery to accomplish this. This is what i have so far: var updateUserDate = function(data){ var table = data.table; var rowId = data.rowId; var editedDate = data.editedDate; var editedBy = data.editedBy; //alert(table+' - '+rowId+' - '+editedDate+' - '+editedBy); $('"#'+table+' .row'+rowId+' .newEditedDate"').html('"'+editedDate+'"'); } var submitDataCheckbox = function(target){ var project = target.attr('project'); var tableName = target.attr('table'); var rowId = target.attr('rowId'); var checkboxValue = (target.attr('checked'))?true:false; $.ajax({ type: 'GET', url: '/checklistpost.php?projectId='+project+'&table='+tableName+'&rowId='+rowId+'&value='+checkboxValue, success: function(data){ updateUserDate(data); }, error: function(){ alert('There was an error submitting data to the database.'); }, dataType: 'json' }); } The `checklistpost.php` page takes the variables that are in the query string and posts them to the database. It also then puts the variables in an array which is then encoded in json so that i have a json object to work with. Basically, i am trying to take that json object that gets called back and use it to update the span as mentioned above. When i have used an `alert()` inside of the `updateUserDate` function before to verify that i can see the variables and they all have the right data (you can see the code i used to do this is commented out). However, whenever i try and use the variables with jQuery as you see on the 6th line of the code. It doesn't do anything. BTW, The jQuery code that should be output based on what is written above should look like this `$("#tableName .row1 .newEditedDate").html("April 14, 2011 @ 5:15pm")` What am i missing? Thanks in advance for any help!
Are you using the jQuery validate plugin anyhwere? Some plugins like old versions of jQuery validate can modify the global ajaxSetup() and cause this sort of thing to fail.

以上就是jQuery ajax callback not firing jQuery code.的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » jQuery 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准