Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing a jquery variable

i'm having trouble with the following jquery code

$this->registerJs(
    'jQuery(document).ready(function($){

    $(".member").on("change",function(){
        var id = $(this).attr("id");
        // alert(id);
        var n = $(this).val();
        // alert(n);
        $.post("'.\Yii::$app->getUrlManager()->createUrl(['death/stl_set_relation','id'=>'+id'])
            .'&name="+id) 


        });

      });'
);

i want the ajax link to be like this http://192.168.1.4/~user/church/backend/web/death/stl_set_relation?id=20&name=1

but with my code i'm not able to pass value of id correctly. what my code creates is the following url

http://192.168.1.4/~user/church/backend/web/death/stl_set_relation?id=%2Bid&name=20

i also tried like this

$.post("'.\Yii::$app->getUrlManager()->createUrl(['death/stl_set_relation','id'=>'"+id"'])
                .'&name="+id) 

but it didn't give me the desired result

how can i pass the value of id correctly?

like image 866
Bloodhound Avatar asked Dec 02 '15 04:12

Bloodhound


1 Answers

try like this may be it will work..

$.post("'.\Yii::$app->getUrlManager()->createUrl(['death/stl_set_relation','id'=>'"+id+"'])
        .'&name="+n);
like image 137
Rumes Shyaman Avatar answered Sep 30 '22 12:09

Rumes Shyaman