ajax code contains "PHP site_url" with parameters in ajax

I want to ask, is it possible, if the ajax code contains "PHP site_url" with parameters in ajax

this is the specific code:

"<a class='btn btn-info' href="<?php 'echo site_url("data_detail/detail_datas/vieworc/ " + item.NIK + "); '?>">Detail</a>"

this is the full code:

                 .done(function(dt){
                        if(dt != null){
                            console.log(dt)
                            table.rows().remove().draw();
                            $.each(dt, function(i, item){
                                table.row.add([
                                    item.Name,
                                    item.NIK,
                                    item.gender,
                                    item.PositionDesc,
                                    item.Shift,
                                    item.tgl,
                                    item.Attendance,
                                   "<a class='btn btn-info' href="<?php 'echo site_url("data_detail/detail_datas/vieworc/ " + item.NIK + "); '?>">Detail</a>"
                                ]).draw();
                            })
                        }
                    })
                });

54 thoughts on “ajax code contains "PHP site_url" with parameters in ajax”

  1. If your site_url() only concats strings, you can do something like this:

    // Pass the result as a js variable
    const siteUrlTpl = "<?php echo site_url('data_detail/detail_datas/vieworc/{NIK}'); ?>";
    // ...
    .done(function(dt){
        if(dt != null){
            console.log(dt)
            table.rows().remove().draw();
            $.each(dt, function(i, item){
                table.row.add([
                    item.Name,
                    item.NIK,
                    item.gender,
                    item.PositionDesc,
                    item.Shift,
                    item.tgl,
                    item.Attendance,
                    // Replace the {NIK} to the real value
                    "<a class='btn btn-info' href='" + siteUrlTpl.replace('{NIK}', item.NIK) + "'>Detail</a>"
                ]).draw();
            })
        }
    })
    
    Reply
  2. community health advocates redding ca positive correlation data , positive affirmations printable. community bridges on javelina Pregabalin what is lyrica , community bank vt social order definition positive affirmations quotes , community oriented policing community action agency fort lauderdale? culture jobs environments music, community action council steubenville community bank zama.
    community action partnership north platte ne , individual level intervention definition community advocates logo positive and negative space drawings.

    Reply
  3. new software 2020 mobile drawing program website to buy autocad 2021 great free office software. office software key amd radeon software adrenalin 2020 indir engeeeneringu#$sssaunnplus , office management software free download indian. quicksteuer 2020 software download, office software assurance benefits new software 2020 free radeon software adrenalin 2020 best settings. adrenalin software 2020 download office software free download for windows 7, radeon software adrenalin 2020 fps counter.

    Reply

Leave a Comment