edit_in_place プラグインを使用しています。
データベースの値も更新しています。そのため、値を編集する前に確認ポップアップを使用しています。ユーザーが [はい] ボタンをクリックすると更新されます。それ以外の場合は更新されません。はい、操作はうまく機能していますが、[いいえ] をクリックすると、データベースで値が変更されていなくても問題ありませんが、Web ページでは表示されているように見えます。Web ページでも変更を停止するにはどうすればよいですか。
これは私のHTMLコードです:
<?
$e_c_query = "select * from category order by id desc";
$e_c_result = mysql_query($e_c_query);
while($e_c_row = mysql_fetch_object($e_c_result))
{
?>
<tr class="highlighter">
<td class="editable-2" id="<?=$e_c_row->id?>" align="center"><div id="<?=$e_c_row->id?>"><?=$e_c_row->category_name?></div></td>
</tr>
<?
}
?>
Jクエリコード:
$('.editable-2').editable({onSubmit: submitData});
function submitData (content) {
//alert('aa');
if(content.previous==content.current || content.current == "")
{
}
else{
var yes = confirm("Are you sure to Edit");
if(yes)
{
$.get('change_categ.php', {already_categ_val : content.previous, categ_name: content.current },function(data){
if(data=='1')
{
document.getElementById('manual_msg_div').className='msg-div';
document.getElementById('manual_msg_div').innerHTML="Category Updated Successfullly";
$('#manual_msg_div').append('<br/>');
}
});
}else{
}
}
}
PHPコード
<? $already_categ_val = $_GET['already_categ_val'];
$categ_name = $_GET['categ_name'];
mysql_query("update category set category_name='".$categ_name."' where category_name='".$already_categ_val."'") or die(mysql_error());
//echo "update category set category_name='".$categ_name."' where category_name='".$categ_name."'";
if(mysql_affected_rows() == 1)
echo "1";
else {
echo "0";
}
?>