I use in my Ajax.Request my jsp. (Prototype)
Somehow I can pass extra parameters in the anonymous function onComplete?
For example,
function save() {
var pars = "param1=date";
new Ajax.Request('algo.ctr', {
parameters: pars,
onComplete: f,
});
}
var f = function (e) {
alert(e.status);
}
I want to use parameter e but also other.
I do not want to use global variables.
The idea is to run multiple concurrent requests and when each one finishes doing someth开发者_如何学Going with an element that I put.
Generally you cannot "add parameters" to the Prototype function's native signature. But you can do something like this:
function mySuccessFunction( a, b, c ) {
alert( "Success!" + a + b + c ) ;
}
new Ajax.Request(url, {
method: 'get',
parameters: {company: 'example', limit: 12} // use an object literal
// for parameters, not a query string
onSuccess: function( transport ) {
mySuccessFunction( transport, 'param1', 'param2' ) ;
}
});
Note here I've passed parameters as an object literal and attached to the onSuccess event instead of the onComplete event.
精彩评论