xhr.onreadystatechange = function()
{
- var json = null;
- if( xhr.getResponseHeader("Content-Type") == "application/json" ) {
- try {
- json = eval('(' + xhr.responseText + ')');
- }
- catch(e) {
- json = null;
+ if( xhr.readyState == 4 ) {
+ var json = null;
+ if( xhr.getResponseHeader("Content-Type") == "application/json" ) {
+ try {
+ json = eval('(' + xhr.responseText + ')');
+ }
+ catch(e) {
+ json = null;
+ }
}
- }
- if( xhr.readyState == 4 ) {
callback( xhr, json );
}
}
this._encode = function(obj)
{
+ obj = obj ? obj : { };
+ obj['_'] = Math.random();
+
if( typeof obj == 'object' )
{
var code = '';
for( var k in obj )
code += ( code ? '&' : '' ) +
k + '=' + encodeURIComponent( obj[k] );
+
return code;
}