我想你需要$ this-> encrypt-> encode方法在你的JS文件中使用的結果。所以你需要使用XMLHttpRequest來檢索它。
var PId = 12;
var catId = 3;
var Param = 'productid='+PId+'&CatId='+catId;
var req = new XMLHttpRequest();
var encriptedCode;
req.open('GET', 'path/to/your/file.php?' + Param, true);
req.onreadystatechange = function (aEvt) {
if (req.readyState == 4) {
if(req.status == 200) {
encriptedCode = req.responseText;
// Do some something with your encrypted code
} else {
// Handle error here
}
}
};
req.send(null);
和PHP文件應該看起來像這裏
<?php
// Load here libs for encryption
$productId = (int)$_GET['productid'];
$catId = (int)$_GET['CatId'];
echo $encryptObj->encrypt->encode($productId, $catId);
這需要與阿賈克斯 – SuperDJ
做需要從阿賈克斯返回了整個事情,並通過只有JS作爲PARAM? – sbrsantanu
順便說一句,你可以使用JavaScript編碼或它的祕密? – Kristiyan