Good day. Here, I met a wonderful framework - qooxdoo.
I am writing ... writing and writing to the moment when I need to pass some parameters to AJAX. Here is the code for this class:
qx.Class.define("myhobby.api", { extend: qx.io.remote.Request, members : { call: function(fname, obj, callback){ this.setUrl("api.php"); this.setMethod("POST"); this.setData("act=" + fname); this.setAsynchronous(false); this.addListener("completed", function (e) { callback(e.getContent()); }); console.log(this.removeListener); this.send(); } }
});
Further, for the sake of interest, I created a button and hung on it the event of executing the call function of this class. Code:
var button1 = new qx.ui.form.Button("First Button", "myhobby/test.png"); var api = new myhobby.api(); button1.addListener("execute", function(e) { api.call(Math.random(10000, 9999), {name: 1}, function(e){ alert(e); }); });
The most indecent thing is that everything works fine only when you first click on the button. Now trace:
- We press on the button, api.call works (It always works)
- Next, we get into the call function, the listener fires, calls the callback function and passes it to it.
So here. On the second click of some x ... hell, the listener does not want to re-track the AJAX completion event. Do not understand why.
If there are comrades here who have worked with this framework ... I would be extremely happy :)) I hope for you :))
PS Digging on the Internet for a long time, did not find the answer.