我使用$.post
将值从当前页面传递到另一个页面以删除一些数据。但价值没有发布。我也试过了.get
,但仍然无法正常工作。请提出解决问题的方法。
<i title="Delete" class="icon-remove-sign icon-2x" onClick=" myFunction('<?php echo $val['id']?>','delete_pahse')"></i>
<script>
function myFunction(rowId,delet) {
if (confirm("Are You Sure to Delete ") == true)
{
$.get("?action=studentDetail&student_id=<?php echo $_GET['student_id'];?>&rowId="+rowId+"delet="+delet),(function(data){
document.getElementById('progress').style.display = "none";
if(data){
alert('The Selected Record Is Successfully Deleted');
}else{
alert('The Selected Record Is Not Successfully Deleted');
} ;
});
}
document.getElementById("demo").innerHTML = x;
}
</script>
答案 0 :(得分:0)
在send.php中
<?php
$mydata="This is my string being passed to another php";
header("Location: http://xyzphp.in/Receive.php?msg=$mydata");
?>
在Receive.php中
<?php
$receive = $_GET['msg'];
echo "Data Received";
echo $receive;
?>
答案 1 :(得分:0)
看起来你错过了&#39;&amp;&#39;之前&#39; delet =&#39;在您的$ .get网址中。这会导致它弄乱rowId - 而不是rowId = 5,它会看到rowId = 5delet =。
答案 2 :(得分:0)
@ user3300358,你可以试试下面的JS代码:
$.ajax({
type:"POST",
url:"YOUR URL",
data: { student_id: student_id, rowId: rowId, delet: delet},
success : function(data) {
if(data){
alert('The Selected Record Is Successfully Deleted');
} else {
alert('The Selected Record Is Not Successfully Deleted');
}
},
error : function() {
alert('Something went wrong. Please try again');
}
});
如果您还有任何问题,请告诉我。