Sunday, 15 April 2012

javascript - How to onClick in Ajax Process -


I have added the html code in the ajax process, but I have encountered a problem while using the onclick function .


Expected results will show "12"
However, the problem has been received "undefined" value.

  function getValue () {var val = $ (this) .find ('ImageClass'). Val (); Warning (val); } Function getImage () {$ .ajax ({type: "GET", url: 'image.php? Id =' + id, async: false, before: function (x) {if (x & x; Override mime type) {x.overrideMimeType ("app / j-son; charset = UTF-8"}}}, datatype: "jason", success: function {var html = '';} html + = ' 
Input class = "Image class" type = "hidden" value = "12" /> '+' & lt; img src = "img / '+ ID + '.png "style =" width: 200px; "& gt; & lt; / div>' + '& lt; / div & gt; $ $ (' content ') .HTML (html) ;}}); }

You can also create a custom function with delegation:

$ (document) .on (".toClick", function getValue () {// to take action here}};

Your HTML

  html = = '
Input class = "imageClass" type = "hidden" value =' 12 '/>' + '& lt; img src = 'Img /' + id + '.png "style =" width: 200px; "& gt; & lt; / div & gt;' + '
or send it to the HTML function

  html + = '
& # 39; & # 39; & lt; img src =" img / '+ id +' .png "style =" width: 200px; "& gt; & lt; / div & gt; + '

and the function should be:

  function getValue (e) {var val = $ (e ) .find ('. ImageClass'). Val (); Warning (Val);}  

Note: Inline function has not been re-found, instead use Event Rep.


No comments:

Post a Comment