Problems with client.core.request.send function.

35 views
Skip to first unread message

bulldiserFNF

unread,
Feb 10, 2012, 10:57:43 AM2/10/12
to APE Project
Hello everyone,
I'm new to APE and I've been slowly working through my issues.
The discussion board has been very helpful in my troubles and I'm
hoping to receive some help on my latest issue.

I am recieving an error when I run the client.core.request.send
function. The error I'm receiving is this:

Error: this.xhr.open is not a function
Source File: http://ape-test.local/APE_JSF/Source/mootools-core.js
Line: 1611

Here is the code that contains the calling function:

client.addEvent('ready', function() {
//send getInfo command
client.core.request.send('getInfo');
});

Here is the code located on the APE Server:

Ape.registerCmd('getInfo', true, function(cmd) {
//Get data from MySQL table
sql.query('SELECT * FROM smoke_processes', function(res,
errorNo) {
if (errorNo) {
Ape.log('Request error : ' + errorNo + ' : '+
this.errorString());
return ['101', 'MYSQL_ERROR'];
} else {
//Display to logs data received from mysql
Ape.log('Fetching ' + res.length + ' result(s)');

Ape.log('- Environment : ' + res[0].Environment + '\n-
Version : ' + res[0].Version);

cmd.sendResponse('info', res[0]); //Send first result
to client
}
});
})

And the code from mootools-core.js. The line that is failing is
this.xhr.open(method.toUpperCase(), url, this.options.async);:

send: function(options){
if (!this.check(options)) return this;
this.running = true;

var type = $type(options);
if (type == 'string' || type == 'element') options = {data:
options};

var old = this.options;
options = $extend({data: old.data, url: old.url, method:
old.method}, options);
var data = options.data, url = String(options.url), method =
options.method.toLowerCase();

switch ($type(data)){
case 'element': data = document.id(data).toQueryString(); break;
case 'object': case 'hash': data = Hash.toQueryString(data);
}

if (this.options.format){
var format = 'format=' + this.options.format;
data = (data) ? format + '&' + data : format;
}

if (this.options.emulation && !['get', 'post'].contains(method)){
var _method = '_method=' + method;
data = (data) ? _method + '&' + data : _method;
method = 'post';
}

if (this.options.urlEncoded && method == 'post'){
var encoding = (this.options.encoding) ? '; charset=' +
this.options.encoding : '';
this.headers.set('Content-type', 'application/x-www-form-
urlencoded' + encoding);
}

if (this.options.noCache){
var noCache = 'noCache=' + new Date().getTime();
data = (data) ? noCache + '&' + data : noCache;
}

var trimPosition = url.lastIndexOf('/');
if (trimPosition > -1 && (trimPosition = url.indexOf('#')) > -1) url
= url.substr(0, trimPosition);

if (data && method == 'get'){
url = url + (url.contains('?') ? '&' : '?') + data;
data = null;
}

this.xhr.open(method.toUpperCase(), url, this.options.async);

this.xhr.onreadystatechange = this.onStateChange.bind(this);

this.headers.each(function(value, key){
try {
this.xhr.setRequestHeader(key, value);
} catch (e){
this.fireEvent('exception', [key, value]);
}
}, this);

this.fireEvent('request');
this.xhr.send(data);
if (!this.options.async) this.onStateChange();
return this;
},

Beldar

unread,
Feb 11, 2012, 11:21:07 AM2/11/12
to APE Project
Hi,

First of all from what I read on these forums and my own experience
the server side mysql js stuff doesn't work at all.

Second I would try changing the transport method.

Hope it helps.
Reply all
Reply to author
Forward
0 new messages