0
我需要在codeigniter中創建國家下拉列表。 onchange事件即時通訊調用項目的另一個控制器的名稱是ajax.php我需要知道如何獲取URL併發送數據到codeigniter中的URL。如何從控制器調用ajax函數...在codeigniter中
我的AJAX功能
var base_url = "<? echo base_url()?>";
function getstate(value) {
if (value !== '') {
//alert('test');
$.ajax({
type: "POST",
url:base_url+"adminzone/ajax/ajax.php",
data: "do=getstate&value=" + value,
success: function(msg) {
alert(msg);
//$('#psid').html("<img src='images/spacer.gif'>");
$('#reg1').html(msg);
//
//$('#sid').sSelect({ddMaxHeight: '300px'});
},
error: function() {
//alert('some error has occured...');
},
start: function() {
//alert('ajax has been started...');
}
});
}
}
我的Ajax控制器是針對
$('#countryfield').change(function() {
var passedvalue = $('#countryfield').val();
var path = base_url+"ajax/getState";
$.ajax({
type: "POST",
url: path,
data: {'passedvalue': passedvalue},
success: function(data) {
if (data) {
alert(success);//task done on success
}
},
error: function() {
alert('some error occurred');
},
});
})
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
//error_reporting(0); class ajax extends CI_Controller {
public function __construct() {
parent::__construct();
if (!$this->session->userdata('admin_logged_in')) {
redirect('adminzone');
}
$this->load->model('doctor_model');
}
public function getstate(){
echo $this->input->post();exit;
}
}