I use this pseudo-class to make ajax request to server:
function RequestManager(url, params, success, error){
//save this ajax configuration
this._ajaxCall = null;
this._url= url;
this._type = params.type;
this._success = function(){
alert("ok");
};
this._error = function(){
alert("ko");
};
}
RequestManager.prototype = {
require : function(text){
var self = this;
this._ajaxCall = $.ajax({
url: this._url,
type: this._type,
data: text,
success: function(xmlResponse){
var responseArray = [];
var response = _extractElements(xmlResponse, arrayResponse);
self._success(response);
},
error: self._error,
complete : function(xhr, statusText){
alert(xhr.status);
return null;
}
});
}
This is php that will be loaded:
<?php
header('Content-type: text/xml');
//do something
$done = true;
$response = buildXML($done);
$xmlString = $response->saveXML();
echo $xmlString;
function buildXML ($done){
$response = new SimpleXMLElement("<response></response>");
if($done){
$response->addChild('outcome','ok');
}
else{
$response->addChild('outcome', 'ko');
}
return $response;
}
When i instantiate a new object, and i use it to load a request, it always return to me error, and status code is 0. Server correctly generates an xml document. Why i can't get a correct 200 code back?