2010-09-25 9 views
0

Internet Explorer semble ignorer cet appel de fonction .live lors de la mise à jour des enregistrements, mais cela fonctionne très bien dans FF.La fonction "Mise à jour" ne fonctionne pas dans IE 7 ou 8 mais fonctionne dans Firefox

si

$ ("forme # updateForm"). Live ("soumettre", la fonction () {

line is changed to 

$ ("forme # updateForm") .live ("click", function() {

la fonction de mise à jour est de travail ing parfaitement dans IE, mais dans Firefox si je clique sur un objet qu'il faut des données avant que je fasse quelque chose .... s'il vous plaît me suggérer, aider quelqu'un s'il vous plaît ...

index.php

<html><head><title>Testing AJAX</title> 
<script type="text/javascript" src="jquery.js"></script> 
</head><body> 
<div class="container"> 
    <form id="submit" method="post"> 
     <fieldset><legend>Enter Information</legend> 
      <label for="actnam" >Activity  : </label><input id="actnam" name="actnam" class="text" size="20" type="text"> 
      <label for="actres" >Responsibility : </label><input id="actres" name="actres" class="text" size="20" type="text"> 
      <label for="actdat" >DAte   : </label><input id="actdat" name="actdat" class="text" size="10" type="text"> 
      <label for="actsta" >status   : </label><input id="actsta" name="actsta" class="text" size="20" type="text"> 
      <label for="actcom" >comments  : </label><input id="actcom" name="actcom" class="text" size="20" type="text"> 
     <input type="submit" value="Add"> 
     </fieldset> 
    </form> 
    <div class="name_list"></div> 
    <div class="update_form"></div> 
</div> 

<script type="text/javascript"> 

$(document).ready(function(){ 

     function loadList(){ 
     // load list start 
       $.ajax({ 
        url: "load-list.php", 
        cache: false, 
        success : function(html){ 
          $(".name_list").html(html); 
           } 
         }); 
      } 
loadList(); 
     $("form#submit").submit(function() { 
     // we want to store the values from the form input box, then send via ajax below 
      var x=window.confirm("Are you sure you want to delete this item?") 
      var actnam = $('#actnam').attr('value'); 
      var actres = $('#actres').attr('value'); 
      var actdat = $('#actdat').attr('value'); 
      var actsta = $('#actsta').attr('value'); 
      var actcom = $('#actcom').attr('value'); 
      if (x==true){ 
         $.ajax({ 
        type: "POST", 
        url: "save.php", 
        data: "actnam="+ actnam +"& actres="+ actres +"& actdat="+ actdat + "& actsta="+ actsta +"& actcom="+ actcom, 
        success: function(){ 
          loadList(); 
            } 
           }); 
         } 
     return false; }); 
     $(".delete_button").live("click", function(){ 
      //this deletes the row clicked on with an alert and then reloads the list 
      var idvaluein = $(this).attr("id"); 
      var x=window.confirm("Are you sure you want to delete this item?"); 
       if (x==true){ 
        $.ajax({ 
        type: "POST", 
        url: "delete.php", 
        data: "id="+ idvaluein, 
        success: function(){ 
          loadList(); 
           } 
          }); 
           } 
      return false;  }); 
     $(".update_button").live("click", function(){ 
      //this loads the update form 
      var idvaluein = $(this).attr("id"); 
      var x=window.confirm("Are you sure you want to update this item?"); 
      if (x==true){ 
      alert(idvaluein); 
      $.ajax({ 

       url: "update-form.php", 
       data: "id="+ idvaluein, 
       cache: false, 
       success: function(html){ 
         $(".update_form").html(html); 
          } 
         }); 
       } 
      return false; });  
       $("form#updateform").live("submit", function(){ 
        var actnam = $('#actnam_update').attr('value'); 
         var actres = $('#actres_update').attr('value'); 
         var actdat = $('#actdat_update').attr('value'); 
        var actsta = $('#actsta_update').attr('value'); 
        var actcom = $('#actcom_update').attr('value'); 
        var idvaluein = $('#id_update').attr('value'); 
      $.ajax({ 
       type: "POST", 
       url: "update.php", 
       data: "actnam="+ actnam +"& actres="+ actres +"& actdat="+ actdat +"& actsta="+ actsta +"& actcom="+ actcom+"& id="+ idvaluein, 
       success: function(){ 
        $(".update_form").empty(); 
        loadList(); 
       } 
      }); 
      return false; 

     }); 
}); 
</script> </body></html> 

<?php 
$hostname="localhost"; 
$username="root"; 
$password=""; 
$dbname="stact"; 

$conn = mysql_connect($hostname,$username,$password) or die ('Not Connecting to the database'); 
@mysql_select_db($dbname) or die ('Not accessing table'); 

$idvalue=substr($_GET['id'],7); 

$sql="SELECT * FROM act_tab WHERE slno='$idvalue'"; 

$query=mysql_query($sql); 

$result = mysql_fetch_assoc($query); 

?> 
<form id="updateform" method="post"> 
    <fieldset> 
     <legend>Update Activity</legend> 
     <label for="actnam_update">Activity  :</label><input id="actnam_update" name="actnam_update" class="text" size="20" type="text" value="<?php echo $result['act_nam']; ?>"> 
     <label for="actres_update">Responsibility :</label><input id="actres_update" name="actres_update" class="text" size="20" type="text" value="<?php echo $result['act_res']; ?>"> 
     <label for="actdat_update">Date   :</label><input id="actdat_update" name="actdat_update" class="text" size="10" type="text" value="<?php echo $result['act_dat']; ?>"> 
    <label for="actsta_update">status   :</label><input id="actsta_update" name="actsta_update" class="text" size="20" type="text" value="<?php echo $result['act_sta']; ?>"> 
    <label for="actcom_update">Comments  :</label><input id="actcom_update" name="actcom_update" class="text" size="20" type="text" value="<?php echo $result['cct_com']; ?>"> 
     <input id="id_update" size="20" type="hidden" value="<?php echo $result['slno']; ?>"> 
    <input type="submit" value="Update">   
    </fieldset> 
</form> 

mise à jour. php

<?php 

    $hostname="localhost"; 
    $username="root"; 
    $password=""; 
    $dbname="stact"; 
    $conn = mysql_connect($hostname,$username,$password) or die ('Not Connecting to the database'); 
    @mysql_select_db($dbname) or die ('Not accessing table'); 
    // CLIENT INFORMATION 
    $actnam = htmlspecialchars(trim($_POST['actnam'])); 
    $actres = htmlspecialchars(trim($_POST['actres'])); 
    $actdat = htmlspecialchars(trim($_POST['actdat'])); 
    $actsta = htmlspecialchars(trim($_POST['actsta'])); 
    $actcom = htmlspecialchars(trim($_POST['actcom'])); 
    $idvaluein = htmlspecialchars(trim($_POST['id'])); 

    $rem = "UPDATE act_tab SET act_nam='$actnam',act_res='$actres',act_dat='$actdat',act_sta='$actsta',cct_com='$actcom' WHERE slno='$idvaluein'"; 

mysql_query($rem) or die(mysql_error()); 
mysql_close($conn); 
?> 

charge list.php

<?php 
$hostname="localhost"; 
$username="root"; 
$password=""; 
$dbname="stact"; 

$conn = mysql_connect($hostname,$username,$password) or die ('Not Connecting to the database'); 
@mysql_select_db($dbname) or die ('Not accessing table'); 

$sql='SELECT * FROM act_tab ORDER BY act_dat'; 
$query=mysql_query($sql); ?> 

<table width="100%" border="1" cellspacing="1" bordercolor="#00CC33" id="thetable"> 

<?php while($result = mysql_fetch_assoc($query)){?> 
<div class="element" id="element-<?php echo $result['slno']; ?>"> 
<tr> 
     <td><?php echo $result['act_nam']; ?></td> 
    <td> <?php echo $result['act_res']; ?></td> 
     <td> <?php echo $result['act_dat']; ?></td> 
    <td> <?php echo $result['act_sta']; ?></td> 
     <td> <?php echo $result['cct_com']; ?></td> 
    <td> <a href="javascript:void(0);" id="<?php echo $result['slno']; ?>" class="delete_button">Delete</a></td> 
    <td> <a href="javascript:void(0);" id="update-<?php echo $result['slno']; ?>" class="update_button">Update</a></td> 
    </tr> 
<?php } ?> 
</div> 
</table> 
+0

Peut-être avez-vous un problème quelque chose comme ceci: http://stackoverflow.com/questions/3656321/form-submition-with-jquery-is-not-working-correctly-with-ie8 – NAVEED

+0

Quelle version de jQuery êtes-vous? en utilisant? –

+0

Testé sur toutes les versions de jquery ... mais ne fonctionnant pas. –

Répondre

0

known bug

Avez-vous essayé d'appeler live ('submit') AVANT tout le live ('clic') dans votre fonction?

+0

Oui Mat j'avais fatigué d'abord en utilisant soumettre .. mais cela fonctionne uniquement avec Fire Fox pas dans IE. puis j'ai choisi de cliquer et de changer les événements qui ont fonctionné cela n'a pas fonctionné parfaitement et aussi ce n'est pas la meilleure alternative à soumettre comme vous le savez. –