Message: Invalid argument supplied for foreach in CodeIgniter

后端 未结 3 1990
名媛妹妹
名媛妹妹 2021-01-17 06:06

i am facing few issues during an application of Codeigniter -- Created an function like

function searchUnivtab() {
        $country = $this->input->po         


        
相关标签:
3条回答
  • 2021-01-17 06:23
    function getSearchUniversity() {
      country = jQuery('[name=countryKey]').val();
      state = jQuery('[name=stateKey]').val();
      level= jQuery('[name=level]').val();
      degType= jQuery('[name=degType]').val();
      jQuery.ajax({
        type: "POST",
        url:baseurl+ 'welcome/searchUnivtab', 
        cache: false,
        data: {countryKey: country, stateKey: state, level: level, degType: degType},
        error: function()
        {
          //notify('Error: Your request could be processed.. try again..!!');
        },
        success: function(html)
        {
          jQuery('[name=universityList]').html(html);
          return false;
        }
      }); 
    }
    
    0 讨论(0)
  • 2021-01-17 06:29

    Remove @ in the following line to see if it produces any error so replace

    $data = @$this->get->getSearchedUniversityTab($country, $state, $level, $degType[1]);
    

    with

    $data = $this->get->getSearchedUniversityTab($country, $state, $level, $degType[1]);
    
    0 讨论(0)
  • 2021-01-17 06:36
    if(is_array($data)) {
        foreach($data as $d){
            $html .= '<option value="'.$d['name'].'">'.$d['name'].'</option>';
        }
    } else {
        echo 'data is not an array.';
    }
    
    0 讨论(0)
提交回复
热议问题