jquery .each() and $.post() works only for 1 element

I want to grab all of my class "reserved" (there are table cells). I want to send every cell's ID via jquery $.post() into some php method. Here is my JQuery code: var cell_id; $('.reserved').each(function() { cell_id = $(this).attr('id'); $.post("/controller/method/",{id: cell_id},function(data,status,xhr) { if(status=="success") { } }) }); It works perfectly if only one cell has class reserved, but when there are more than just one - it doesn't work at all!

以上就是jquery .each() and $.post() works only for 1 element的详细内容,更多请关注web前端其它相关文章!

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

评论 抢沙发

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

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