代码在localhost中工作,但它在hostgator服务器中不起作用?

时间:2018-04-18 10:29:54

标签: javascript jquery ajax codeigniter

基于值的

dropdown框应显示在文本字段中,

当前代码在localhost中工作,但不在hostgator服务器上工作

示例国家/地区基于州和州的州/州

<script type="text/javascript">
        $(document).ready(function () {
            $('#state').on('change', function () {
                var stateID = $(this).val();
                if (stateID) {                   
                    $.ajax({                 
                        url: '<?php echo base_url(); ?>index.php/myform/ajax/' + stateID,
                        type: "GET",
                        dataType: "json",           
                        success: function (data) {        
                            console.log(data);
                            var title = [], metatags = [], decription = [];
                            $.each(data, function (key, value) {
                                title.push(value.page_title);
                                metatags.push(value.page_metatags);
                                decription.push(value.page_decription);
                            });
                            $('input[name="city"]').val(title.join(','));
                            $('input[name="Metatags"]').val(metatags.join(','));
                            $('input[name="Description"]').val(decription.join(','));
                        }
                    });
                }
            });
        });
    </script>

routes.php文件

    $route['myform'] = 'welcome';
    $route['myform/ajax/(:any)'] = 'welcome/myformAjax/$1';

的welcome.php

 public function update() {
    $this->load->helper('url');
    $data['state_fetch'] = $this->Question_Insertion_Model->all_Pages_Display();
    $this->load->view('update', $data);
    }
    public function myformAjax($id) {
    $this->db->select('c.*');
    $this->db->where("s.page_id", urldecode($id));
    $this->db->join('kas_all_pages s', 's.page_id = c.page_fk');
    $result = $this->db->get('kas_all_pages_tags c')->result();
    echo json_encode($result);
    }

screenshot

1 个答案:

答案 0 :(得分:1)

index.php中的

只需添加以下代码

  • 注意:如果更改这些,也请更改下面的error_reporting()代码 * / $ _SERVER [ 'CI_ENV'] = '生产';