get id ajax not undifend



我有代码,但没有运行 在巴朗.php我有这个代码:

巴朗.php

<?php
$p=isset($_GET['act'])?$_GET['act']:null;
switch($p) {
default :
echo '':
break;
case "edit":
include "editrefbrg.php";
break;
}

在分页中.php我有以下代码:

帕吉纳蒂奥.php

<td>
<a href="?page=barang&act=edit" target="blank" class="edit" id='.$row["id"].'>
<i class="glyphicon glyphicon-edit"></i>
</a>
</td>

对于 ajax,我使用以下代码:

$(document).on("click",".edit",function(){
	var id = $(this).attr('id');
	
	console.log(id);
	if(confirm("edit Data ?")){
		$.ajax({
			type : "POST",
			data: "id="+id,
			url : "editrefbrg.php?id="+id,
			dataType: "json",
			success: function(result){
			    $(this).attr('id');	
			}
		})
	}else{
		return false;
	}
});

在文件编辑BRG中.php我使用以下代码:

include "config/koneksi.php";
$result ="";
$id = $_GET['id'];
$hasil = mysql_query("SELECT concat(f,'.',g,'.',h,'.',i,'.',j) as id,nm_barang as nama,masa_manfaat as umur FROM ref_barang WHERE  f = SUBSTRING('".$id."',1,2) AND g = SUBSTRING('".$id."',4,2) AND h = SUBSTRING('".$id."',7,2) 
AND i = SUBSTRING('".$id."',10,2) AND j = SUBSTRING('".$id."',13,3) ");
$d = mysql_fetch_array($hasil);
echo'$d["id"] ';

但在 href 错误代码中,例如:

注意:未定义的索引:d:\xampp\htdocs\skripsiphp\editrefbrg.php 在第 5 行中的 id

在你的 ajax 中你有type:"POST",这应该是 ajaxtype:"GET"分页.php文件,因为你是从$_GET访问的。

最新更新