【发布时间】:2021-05-13 12:43:12
【问题描述】:
基本上我有 PHP 代码和 javascript 代码的组合。我的 mySQL 数据是使用 CodeIgniter 加密的,因此要在 json 中加载数据(查看和编辑),我需要再次对其进行解密。我的问题是如何使我的“$x”变量动态化?
谢谢。
function edit_person(id)
{
save_method = 'update';
$('#form')[0].reset();
$('#modal_form').modal({backdrop: 'static', keyboard: true, show: true });
<?php
$x = 13; //<== **i need to make this $x dynamic based on "edit_person(id)"** //
$url = "http://myurlhere.com/main/ajax_edit/".$x;
$datax = file_get_contents($url);
$string = json_decode($datax, TRUE);
?>
$.ajax({
url : "<?php echo site_url('main/ajax_edit')?>/" + id,
type: "GET",
dataType: "JSON",
success: function(data)
{
$('[name="id"]').val(data.id);
// ** below code "firstName" is my decryption requirement ** //
$('[name="firstName"]').val("<?php echo $this->encryption->decrypt($string['firstName']); ?>");
$('#modal_form').modal('show');
},
error: function (jqXHR, textStatus, errorThrown)
{
alert('Error get data from ajax');
}
});
}
【问题讨论】:
标签: javascript php json ajax encryption