[ Поиск ] - [ Пользователи ] - [ Календарь ]
Полная Версия: AJAX
ELked
	if(isset($_GET['hash_file'])){
$hash = $_GET['hash_file'];
json_encode(array('test' => 'test'));
}

Вот так я получаю данные в php файле
Вот так я их отправляю:
	$.ajax({
url: './index.php/',
type: 'GET',
data: {hash_file : file},
dataType: 'text',
success: function (data){
alert(data.test);
}

}
);

Мне выводится undefined, get запрос отправляется, смотрел в фаербаге, ошибок.
ELked
Я так понял, это из-за того что я не написал parseJSON, а еще ответ data получается html страница.
Вот она:

<html>
<
head>
<
link rel="stylesheet" type="text/css" href="style.css">
<
script type="text/javascript" src="./js/jquery-2.0.1.min.js"></script>
<
script type="text/javascript" src="./js/main.js"></script>
</
head>
<
body>
<?php
include './lib/Codeeditor.class.php';
$code = new Editcode;
$code->PATH = "./lib";
echo $code->print_files("*.php", "./lib");
?>
<textarea class="code"></textarea>
</
body>

</
html>


Ну и вот класс:
<?php
class
Editcode{
public $PATH;
public function __construct(){
$this->PATH = "./"; //Путь по умолчанию
}
public function print_files($format){ //Список файлов пути $path, $format - формат файлов

foreach (glob("./".$this->PATH."/".$format) as $files) { //Выводим список файлов с нужным нам расширением
return "<div class='edit' value='".md5(basename($files))."'>".basename($files)."</div>";

}
if(isset($_GET['hash_file'])){
$hash = $_GET['hash_file'];
$response =array('test' => $hash);
echo json_encode($response);

}
}


}


?>


Где я напортачил?
Быстрый ответ:

 Графические смайлики |  Показывать подпись
Здесь расположена полная версия этой страницы.
Invision Power Board © 2001-2024 Invision Power Services, Inc.