I try to wrote ajax request in Yii 1 with jQuery. In my URL i try to append value of id attribute of my link, but I cant do that. Here is my code:
Yii::app()->clientScript->registerScript('vot', "
$(document).ready(function(){
$('.js-register-member').click(function(e){
e.preventDefault();
$.ajax({
method: 'POST',
url: '" . $this->createUrl('cre/register/124'). "',
});
});
});
"); I need to put my parametr where 124 is situated... I try put there somethink like:
$(this).attr('id'); but I get 500 error
Try this. Hope it will work
Yii::app()->clientScript->registerScript('vot', "
$(document).ready(function(){
$('.js-register-member').click(function(e){
e.preventDefault();
var id = $(this).attr('id');
$.ajax({
method: 'POST',
url: '" . $this->createUrl('cre/register/') . "' + id ,
});
});
});
");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.