javascript - PHP Ajax button press conundrum -


i have been trying have button execute php script on page , refresh div tag without success. when remove $ajax part of script buttons change state when add ajax part again nothing happens.

i need load content php file , change button's , div tags state. appreciated can't seem find problem.

<div id="noah-content">                        <script>     $(document).ready(function() {           $("#on'.$id.'").click(function() {             document.getelementbyid("on'.$id.'").disabled = true;              document.getelementbyid("off'.$id.'").disabled = false;                   $.ajax({                 type: "post",                 url: "some.php",                 data: {                     param: $(this).attr("src");                 }             }).done(function( msg ) {                 alert( "data saved: " + msg );             });         });          $("#off'.$id.'").click(function() {             document.getelementbyid("on'.$id.'").disabled = false;              document.getelementbyid("off'.$id.'").disabled = true;           });     });  </script>     <img src="images/about.png" alt="image" id="myimg" /> <input type="submit" class="on" id = "on'.$id.'" value=" on " name="submit"/> <input type="submit" class="off" id = "off'.$id.'" value=" off " name="submit" disabled="disable"/> </div> 

example

lets start evaluating php:

in order run php have open php tags:

 $("#on<?php echo $id ?>")... 

replace everywhere want id appear. debugging, open page source in browser , see being generated:

example:

<input type="submit" class="on" id="on<?php echo $id ?>" value="on" name="submit"/> 

Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

java.util.scanner - How to read and add only numbers to array from a text file -

iphone - Three second countdown in cocos2d -