EG Information
Training Missions
Knowledge Bank
|
|
Enigma Group's Code Bank
Simple Ajax WrapperBy: -epoch- - Date Submitted: 2008-10-20 09:56:21 var AjaxObject = function() {
this.xmlHttp = null
this.transport = null
this.method = "post"
this.url = ""
this.div = ""
this.create = function(url, transport, method) {
this.xmlHttp = initialize()
this.transport = transport
this.url = url
this.method = method
}
this.request = function(params,div) {
this.div = div
var string = this.url + "?" + params
this.xmlHttp.open(this.method,string,true)
this.xmlHttp.onreadystatechange = this.transport
this.xmlHttp.send(null)
}
this.getData = function() {
if (this.xmlHttp.readyState == 4) {
return this.xmlHttp.responseText
}
return null
}
this.getDiv = function() {
return this.div
}
function initialize() {
var xmlHttp=null
try {
xmlHttp=new XMLHttpRequest()
} catch (e) {
try {
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP")
} catch (e) {
try {
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP")
} catch (e) {
alert("Your browser does not support AJAX, please upgrade!")
return false
}
}
}
return xmlHttp
}
}
//this would be used like this...
var chat = new AjaxObject()
chat.create("ajaxChatActions.jsp",chatCallBack,"post")
function chatCallBack() {
var response = chat.getData()
if (response != null) {
var div = chat.getDiv()
}
}
//and a request would be sent like this
chat.request('action=send&random=' + Math.random(),'yourdiv')
|
| Return to
ajax category list |
|
|
Who's Online
483 Guests, 101 Users ckryptix, viper0i0, Diznablo, rabbidmind, asapong, Nasrudin, CollapsingWalls, mehtaparag, bitstrike, jnony, C, Nicid1, Nusquam-Redono-Sapientia, bazcrown, saifulfaizan, The End, Ultraminor, psychomarine, st3alth, themastersinner, pgmrlink, login, lionaneesh, ishkur88, mahraja, Mac, chekifr, gandalf88, Vap0r, t0ast, tantrum6226, BnE, Distorted, Psiber_Syn, Ausome1, invas10n, oldgoat, freedaysbecumei, BinaryShinigami, Rex_Mundi, Red_beard, Strobeflux, s0m3nak3dguy, Descent, teehee, machupicchu, Genetix, Anandarl, NotMyOwn, thegamerdude, Godzila, popo12341234, RedEvolution, velocity_b, myne17, teto111, aVoid, Central-Gsm, 1101, JackalReborn, InjectioN, h4lted, c0re, DisPater, markt4death, splatta, Jackowacko, saint556, Pyron2312, Azerion, howsens, white.hat.gone.bad, vazzilly, pwunkz, Ios, Inverted, QuarterCask, Infernoe11, deskata, cr4ck3rj4ck, Blizer, jasonmax, j0sh, gwenwavor, N4g4c3N, spizeyboy, Network X, Uino59, Jae Cee, ianFDK, saykov, medhaavee, zofy, demonkiller410, Stumble, SaMTHG, kishore, Raze, helasraizam, Venom1019, Jakabo |
| |
|
|
|
|
|