[Webkit-unassigned] [Bug 44849] New: xmlhttprequest event javascript String functions not available
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Sun Aug 29 19:46:39 PDT 2010
https://bugs.webkit.org/show_bug.cgi?id=44849
Summary: xmlhttprequest event javascript String functions not
available
Product: WebKit
Version: 420+
Platform: PC
OS/Version: Linux
Status: UNCONFIRMED
Severity: Major
Priority: P2
Component: JavaScriptGlue
AssignedTo: webkit-unassigned at lists.webkit.org
ReportedBy: ss at tuxclub.org
In a xmlhttprequest progress event callback. I try to use
var t = "test" ;
var p = t.subStr(2);
and it fails
the javascript string functions are not available
CODE *****
function maChat() {
this.url = "/mafw/chat.ma";
}
maChat.prototype = new maWeb( this.url );
function callback( evt, maweb ) {
var t = "test";
var p = t.subStr(2);
var obj = maweb.getObj( evt );
var stat = maweb.getStat( evt );
alert( stat["code"]+stat["text"]+" "+ JSON.stringify( obj ) );
}
function sendmsg( ) {
var cmd = {};
cmd["type"] = "cmd";
cmd["cmd"] = "initdata";
cmd["me"] = 0;
try {
var conn = new maWeb( "http://localhost/mafw/chat.ma" );
conn.send( JSON.stringify ( cmd ), callback );
} catch (e ) {
alert (e);
}
// try {
// var conn1 = new maChat();
// conn1.send( JSON.stringify ( cmd ), callback );
// } catch (e ) {
// alert (e);
// }
};
function sendpush() {
var cmd = {};
cmd["type"] = "cmd";
cmd["cmd"] = "initdata";
cmd["me"] = 0;
try {
var conn = new maWeb( "http://localhost/mafw/chat.psh", true );
conn.setProgress( callback );
conn.send( JSON.stringify ( cmd ), callback );
} catch (e ) {
alert (e);
}
}
CODE2 *********************************
function maWeb( url, push, method ) {
this.method = "POST";
this.multi = false;
this.url = url;
this.self = this;
this.oldLen = 0;
if ( method != undefined )
this.method = method;
if ( push != undefined )
this.multi = push;
var req = new XMLHttpRequest();
this._req = req;
req.multipart = this.multi;
this.send = function( data, loadcb ) {
var self = this;
this._req.onload = function( evt ) {
loadcb( evt, self );
return false;
};
this._req.open( this.method, this.url, true );
try {
this._req.send( data );
} catch (e) {
alert( e );
}
};
this.setProgress = function( func ) {
var self = this;
self._req.onprogress = function ( evt ) {
return func( evt, self );
}
};
this.addCallback = function( name, func ) {
var self = this;
var cb = function ( evt ) {
var r = evt.target;
var s = r.responseText.length;
func( evt, self );
}
switch( name ) {
case "loadstart":
req.onloadstart = cb;
break;
case "progress":
req.onprogress = cb;
break;
case "abort":
req.onabort = cb;
break;
case "error":
req.onerror = cb;
break;
default:
req.addEventListener( name, function ( evt ) {
func( evt, self );
}, false);
};
};
this.abort = function() {
req.abort();
};
this.getObj = function( evt ) {
var r = evt.target;
var str;
switch ( r.readyState ) {
case 4: //Firefox
case 2: //Chrome
str = r.responseText;
break;
case 3: //Chrome
str = r.responseText.subStr( this.oldLen );
this.oldLen = r.responseText.length;
break;
default:
break;
};
try {
var obj = JSON.parse( str );
} catch (e) {
alert( e );
}
return obj
};
this.getStat = function( evt ) {
var r = evt.target;
var stat = {};
stat["code"] = r.status;
stat["text"] = r.statusText;
return stat;
}
};
--
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the webkit-unassigned
mailing list