You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

139 lines
4.1 KiB
JavaScript

/**
* (c) 2010 jxf - rpc module.
*
* The idea of behind this module is fetching data via an RPC-like call:
* . RESTful web services
* . XML/SOAP (not yet implemented)
* . Remote document (HTML; XML; JSON)
* . Local documents (HTML; XML; JSON)
* The module will return the data to a callback function should a parser be specified, the module will parse the data and return the parsed data to the callback function
* This allows the client code to minimize parsing should returned data be in a standard format.
* TODO:
* Improve on how returned data is handled (if necessary).
*/
if(!jx){
var jx = {}
}
x.responseText = jx.ajax.debug [url] ;
callback(x)
}else{
var http = new XMLHttpRequest() ;
http.onreadystatechange = function(){
if(http.readyState == 4){
callback(http)
}
}
//
// In order to insure backward compatibility
// Previous versions allowed the user to set the variable on the wrapper (poor design)
if(this.async != null){
this.setAsync(this.async) ;
}
http.open(method,url,this.obj.async) ;
for(key in this.obj.headers){
value = this.obj.headers[key] ;
http.setRequestHeader(key,value)
}
http.send(this.obj.data)
}
}
var HttpClient = jx.ajax.get ;