Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
代码点火器路由。AJAX使用javascript获取参数_Javascript_Ajax_Codeigniter - Fatal编程技术网

代码点火器路由。AJAX使用javascript获取参数

代码点火器路由。AJAX使用javascript获取参数,javascript,ajax,codeigniter,Javascript,Ajax,Codeigniter,我希望这与Codeigniter一起工作: name = encodeURIComponent( document.getElementById("myName").value); xmlHttp.open("GET", "quickstart.php?name=" + name, true); xmlHttp.onreadystatechange = handleServerResponse; //not relevant for question xmlHttp.send(null);

我希望这与Codeigniter一起工作:

name = encodeURIComponent( document.getElementById("myName").value);

xmlHttp.open("GET", "quickstart.php?name=" + name, true);

xmlHttp.onreadystatechange = handleServerResponse; //not relevant for question

xmlHttp.send(null);
我创建了一个带有参数的函数的控制器,并更改了以前的代码:

xmlHttp.open("GET", "quickstart.php?name=" + name, true);

我使用以下路线(但不起作用):

我的问题是我只写了最后一封信。例如,如果我写“name”,只有“e”作为参数传递。但是所有的信息都被发送出去了。 我的控制器功能如下所示:

public function quickstart($name='')
{
// we'll generate XML output
header('Content-Type: text/xml');
// generate XML header
echo '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
// create the <response> element
echo '<response>';
// retrieve the user name
//$name = $this->input->get('name');

// generate output depending on the user name received from client
$userNames = array('YODA', 'AUDRA', 'BOGDAN');
if (in_array(strtoupper($name), $userNames))
    echo 'Hello, master ' . htmlentities($name) . '!';
else if (trim($name) == '')
    echo 'Stranger, please tell me your name!';
else

echo htmlentities($name) . ', I don\'t know you!';
// close the <response> element
echo '</response>';
}
公共函数快速启动($name='')
{
//我们将生成XML输出
标题('Content-Type:text/xml');
//生成XML标头
回声';
//创建元素
回声';
//检索用户名
//$name=$this->input->get('name');
//根据从客户端接收的用户名生成输出
$userNames=array('YODA','AUDRA','BOGDAN');
if(在数组中(strtoupper($name),$userNames))
回音“你好,大师”。htmlentities($name);
else if(修剪($name)='')
echo‘陌生人,请告诉我你的名字!’;
其他的
“我不认识你!”;
//关闭元素
回声';
}
仅限使用

$route['ajax/quickstart/(:any)'] = "ajax/quickstart/$1";
.

仅限使用

$route['ajax/quickstart/(:any)'] = "ajax/quickstart/$1";

.

它起作用了,但我不得不添加$route['ajax/quickstart']='ajax/quickstart/';$route['ajax/quickstart/(:any)]='ajax/quickstart/$1'@beerLantern,+1,这太完美了:-)它工作了,但我必须添加$route['ajax/quickstart']='ajax/quickstart/';$route['ajax/quickstart/(:any)]='ajax/quickstart/$1'@比兰特恩,+1,太完美了:-)
$route['ajax/quickstart/(:any)'] = "ajax/quickstart/$1";