Reputation: 6264
How can I call dojo.query with button on my page so that I save data in mysql using php?
I need to run the following code on button click:
dojo.query("img",dojo.byId("div1")).forEach( function() {
// this is now the image
dojo.xhrGet( { url: '/somepage.php',
data: { image_name: this.title } // ???: depends on what you want
load: function( data ) {
alert("I worked!");
},
error: function( data ) {
alert("O NOES!!!");
}
}
);
});
Upvotes: 1
Views: 618
Reputation: 8752
Use dojo.connect to set up an event listener for the onclick event of the button. If your button has an id of "btn1", the code would be like this:
dojo.connect(dojo.byId('btn1'), 'onclick', functionNameToRun);
Upvotes: 2