Php Ajax价格过滤器Codeigniter

Php Ajax价格过滤器Codeigniter,php,ajax,codeigniter,Php,Ajax,Codeigniter,Ajax代码: function showProduct(baseurl,sortbyid) { //alert('123'); if (sortbyid=="") { document.getElementById("sortMyData").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp

Ajax代码:

function showProduct(baseurl,sortbyid)
{
    //alert('123');
if (sortbyid=="")
  {
    document.getElementById("sortMyData").innerHTML="";
  return;
  } 
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("sortMyData").value=xmlhttp.responseText;
    }
  }               
      url = baseurl + 'product/sortby/'+sortbyid; 
      //alert(url); 
    xmlhttp.open("GET", url, true);
    xmlhttp.send();   
    return false;
  }
控制器:

public function sortby()
        {
            $lowhigh=$this->uri->segment(3);
            $lowtohighprice=$this->product_model->getlowtohighprice($lowhigh);
            $this->load->view('sortby');
        }
型号:

公共函数getlowtohighprice() { $lowtohighQuery=$this->db->query(“按价格订单按价格ASC从产品组中选择*)


我正在尝试使用ajax过滤器从低到高的价格获取产品。我已经执行了查询,它运行良好。我对ajax不熟悉,所以我希望ajax代码存在问题。我没有遇到任何问题,我使用的是codeigniter框架。提前感谢。

您必须将数据传递到视图,以便视图可以显示查询结果

public function sortby()
{
    $lowhigh = $this->uri->segment(3);

    $lowtohighprice = $this->product_model->getlowtohighprice($lowhigh);

    // The second parameter $lowtohighprice is the data
    $this->load->view('sortby', $lowtohighprice); 
}
public function sortby()
{
    $lowhigh = $this->uri->segment(3);

    $lowtohighprice = $this->product_model->getlowtohighprice($lowhigh);

    // The second parameter $lowtohighprice is the data
    $this->load->view('sortby', $lowtohighprice); 
}