2016-06-14 18 views
-1

このような状況でajaxリクエストを作成するのにお手伝いできますか?私はok idをクリックしたいと思います。私はちょうどそれの内容を更新し、データベースに保存したいと思う。誰でもここで私を助けてくれることを願っています。ありがとうございました。jQueryを使用したAJAX POSTリクエスト

VIEWファイル:

<tbody> 
    <?php foreach ($ds_name as $dsname): ?> 
    <tr> 
     <td><div class="text-infoo<?= $dsname->id ?>"><?= $dsname->name ?></div></td> 
     <td> 
      <a href="#" id="edit<?= $dsname->id ?>"><span class="glyphicon glyphicon-pencil"></span></a> 
      <a href="#" id="ok<?= $dsname->id ?>"><span class="glyphicon glyphicon-ok"></span></a> 
      <a href="#"><span class="glyphicon glyphicon-remove"></span></a> 
     </td> 
    </tr> 
    <?php endforeach; ?> 
</tbody> 

<?php foreach ($ds_name as $dsname): ?> 
    $('#edit<?= $dsname->id ?>').click(function() { 
     var text = $('.text-infoo<?= $dsname->id ?>').text(); 
     var input = $('<input id="attribute<?= $dsname->id ?>" type="text" data-id="<?php echo $ds_content->id; ?>"value="' + text + '" />'); 
     $('.text-infoo<?= $dsname->id ?>').text('').append(input); 
     input.select(); 

     input.blur(function() { 
      var text = $('#attribute<?= $dsname->id ?>').val(); 
      $('#attribute<?= $dsname->id ?>').parent().text(text); 
      $('#attribute<?= $dsname->id ?>').remove(); 
     }); 
     $('#edit<?= $dsname->id ?>').hide(); 
     $('#ok<?= $dsname->id ?>').show(); 
    }); 
<?php endforeach; ?> 

答えて

0

あなたはこの

$.ajax({ 
      url: "data.php",//file wich has query select to db table 
      data: {id:theid},//describe your data here 
      dataType: 'json',// type of data that will you get (JSON/HTML). 
      type: 'POST',//sending type (POST/GET) 
      success: function(data) { 
       //do change the select option 
      } 
     }); 

グッドラックでそれを行うことができます!

関連する問題