【发布时间】:2017-11-21 15:21:18
【问题描述】:
我需要将变量“idlaw”传递给 base.js,然后从 base.js 传递给 PHP 页面 edit.php
editarLegislacao.php
<input class='btn btn-primary buttonBlue' type='button' name='btnAceitarPend' value='Edit' onClick="javascript:openAreaLaw('editLegislation', 'editlaw','<?php echo $law["idLaw"]?>')"/>
Base.js
function openAreaLaw(closeArea, openArea) {
if ($("#" + openArea).css('display') == 'block')
return;
if(openArea=='applicableLegislation'){
window.location='maps1.php';
return;
}
if(openArea=='editlaw'){
$.post({
url: "views/editarLei.php",
data: {
idLaw: $("#idLaw").val()
},
async: true,
success: function () {
}
});
}
$("#" + closeArea).stop().fadeOut(500);
setTimeout(function () {
$("#" + openArea).stop().fadeIn(500);
}, 504);
}
Edit.php
if( isset( $_POST['idLaw'] ) ) {
$idLaw1 = $_POST['idLaw'];
}
【问题讨论】:
-
您不为此使用会话甚至 cookie 是否有特殊原因?`
-
您的 PHP
if与您正在尝试做的完全相反。只需反转您的比较器。 -
我正在使用会话,但我不需要这种情况
-
我认为 jquery 很好,但下一个 php 文件没有获得值
标签: javascript php jquery post