Reputation: 11
I need pass variable “idlaw” to base.js and then from base.js to PHP page 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'];
}
Upvotes: 1
Views: 70
Reputation: 2350
There's nothing wrong with your jQuery, it's your PHP that needs tweaking:
if( isset( $_POST['idLegislacao'] ) ) {
$idLei = $_POST['idLegislacao'];
}
Upvotes: 0
Reputation: 31
Try this code (corrected if condition and removed space in POST)
if(array_key_exists("idLegislacao", $_POST)) {
$idLei = $_POST["idLegislacao"];
}
Upvotes: 1