Ошибка TypeError: Cannot convert 'xmlDoc' to object
а если делаю как метод котнролера
Код:
class Controller_Login extends Controller
{
...
public function Request()
{
...
$response =
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' .
'<response>' .
'<result>' .
//обращаеться к менеджеру который отвечает за авторизацию
$query->authorisationAJAX($_POST['inputValue'],
$_POST['fieldID']) .
'</result>' .
'<fieldid>' .
$_POST['fieldID'] .
'</fieldid>' .
'</response>';
if(ob_get_length()) ob_clean();
header('Content-Type: text/xml');
echo $response;
}
...
}
{
...
public function Request()
{
...
$response =
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' .
'<response>' .
'<result>' .
//обращаеться к менеджеру который отвечает за авторизацию
$query->authorisationAJAX($_POST['inputValue'],
$_POST['fieldID']) .
'</result>' .
'<fieldid>' .
$_POST['fieldID'] .
'</fieldid>' .
'</response>';
if(ob_get_length()) ob_clean();
header('Content-Type: text/xml');
echo $response;
}
...
}
тогда js выдает ошибку TypeError: Cannot convert 'xmlDoc' to object
что я делаю неправильно ?
Код:
// читает ответ сервера
function readResponse()
{
// получить ответ сервера
var response = xmlHttp.responseText;
// ошибка сервера?
if (response.indexOf("ERRNO") >= 0
|| response.indexOf("error:") >= 0
|| response.length == 0)
throw(response.length == 0 ? "Server error." : response);
responseXml = xmlHttp.responseXML;
xmlDoc = responseXml.documentElement;
result = xmlDoc.getElementsByTagName("result")[0].firstChild.data;
fieldID = xmlDoc.getElementsByTagName("fieldid")[0].firstChild.data;
message = document.getElementById(fieldID + "Failed");
message.className = (result == "0") ? "error" : "hidden";
setTimeout("authorisation();", 500);
}
function readResponse()
{
// получить ответ сервера
var response = xmlHttp.responseText;
// ошибка сервера?
if (response.indexOf("ERRNO") >= 0
|| response.indexOf("error:") >= 0
|| response.length == 0)
throw(response.length == 0 ? "Server error." : response);
responseXml = xmlHttp.responseXML;
xmlDoc = responseXml.documentElement;
result = xmlDoc.getElementsByTagName("result")[0].firstChild.data;
fieldID = xmlDoc.getElementsByTagName("fieldid")[0].firstChild.data;
message = document.getElementById(fieldID + "Failed");
message.className = (result == "0") ? "error" : "hidden";
setTimeout("authorisation();", 500);
}
Во всех браузерах не работает?
Цитата: Phodopus
Во всех браузерах не работает?
Да. опера и хром пробывал
javascript
|
контроллер страницы
метод или функция
|
менеджер
так вот если я код пишу как функция тогда все ок работает , а если как метод тогда TypeError:Cannot convert 'xmlDoc' to object .В обоих случаях исользую один и тот же менеджер один и тот же javascript. То есть ошибка в контроллере а именно в том что он возврощает клиенту или как возврощает
( пробывал echo $response; return $response) .
в этом проэкте одна точка входа в index.php:
Код:
...
switch ($_GET['c'])
{
case 'signup':
$controller = new Controller_SignUp();
break;
case 'login':
$controller = new Controller_Login();
break;
...
$controller->Request();
switch ($_GET['c'])
{
case 'signup':
$controller = new Controller_SignUp();
break;
case 'login':
$controller = new Controller_Login();
break;
...
$controller->Request();
и в javascript к серверному скрипту я обращаюсь так:
Код:
// переменная для хранения адреса удаленного сервера
var serverAddress = "index.php";
...
cache.push("?c=login&inputValue=" + inputValue + "&fieldID=" + fieldID);
//или так
// переменная для хранения адреса удаленного сервера
var serverAddress = "index.php?c=login";
...
cache.push("inputValue=" + inputValue + "&fieldID=" + fieldID);
var serverAddress = "index.php";
...
cache.push("?c=login&inputValue=" + inputValue + "&fieldID=" + fieldID);
//или так
// переменная для хранения адреса удаленного сервера
var serverAddress = "index.php?c=login";
...
cache.push("inputValue=" + inputValue + "&fieldID=" + fieldID);
Выходит что я обращась к index.php а отвечает Controller_Login.php может поэтому ошибка если так тогда как правильно поступить?