السلام عليكم ورحمة الله وبركاته
عندى مشكله فى عرض بيانات بالاجاكس فى codeigniter
عندى نتائج معروضه من قاعدة البيانات اريد لما اضغط على عرض كل نتيجه فيهم يظهر لى كل البيانات الخاصه بهذه النتيجه فى <div> بالاجاكس
جربت كتير وفشلت معى
اليكم الكود الخاص بى
hello all
i have controler
class Test extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->model('product_pics_model');
$q=$this->input->is_ajax_request('q');
}
function index()
{
$data['pics']=$this->product_pics_model->getall();
$this->load->view('test',$data);
}
function getpic($q)
{
$q=$this->input->is_ajax_request('q');
$query=$this->product_pics_model->get_images_byid($q);
$data['row']=$query->row();
$this->load->view('test2',$data);
}
} and view code
[removed]
function showUser(str){
if(str==""){
document.getElementById("txtHint")[removed]="";
return;
}
if(window.XMLHttpRequest){// for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else{// for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200){
document.getElementById("ajax_data")[removed]=xmlhttp.responseText;
}
else{
document.getElementById("ajax_data")[removed]="Loading...";
}
}
//xmlhttp.open("GET","/test/getpic/q="+str,true);
xmlhttp.open("GET","<?php echo base_url(); ?>test/getpic/q="+str,true);
xmlhttp.send();
}
</script>
<ul>
<?php foreach($pics as $pic):?>
<li><a href="#" onclick="showUser(this.value)" value="<?php echo $pic->id; ?>"><?php echo $pic->image1; ?>:<?php echo $pic->id; ?></a></li>
<?php endforeach;?>
</ul>
<div id="ajax_data">
show data here
</div>