Ayip.Eiger
Ayip.Eiger

Reputation: 11

colorbox cannot passing POST data with $(this) selector

I have searched any thread here and still not found for my spesific problem. I have a list of data and every row have editBtn that assign to be as colorbox. My code in below :

$('.editBtn').colorbox({
  href: '<?=site_url('jkitem/editjkitem')?>',
  iframe: false,
  title: 'Change Item',
  transition: 'elastic', 
  speed: 200, 
  opacity: 0.6,
  fadeOut: 300,
  overlayClose: false,
  data: { edited_jkitem : $(this).attr('value')},
  onClosed: function(){
       location.reload();
  }
 });

As seen above, I still cannot pass $(this).attr('value') to my controller. Is there any reason for this problem?

Upvotes: 0

Views: 916

Answers (1)

Kevin B
Kevin B

Reputation: 95020

This is based on comments:

The reason it works for your GET and not POST is because you're doing them two very different ways. If you do your POST the same way you do GET, it will work.

data: function(){ 
    return { edited_jkitem : $(this).attr('value') }
}

Upvotes: 1

Related Questions