views:

131

answers:

1

how can i call dojo.query with button on my page. so that i save data in mysql using php

i need to run 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!!!"); } } ); });

+2  A: 

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);
Swingley