ボタンやリンクをクリックしてデータを返すときに、PHPスクリプトを呼び出すための簡単なjavascript関数を使用しています。私はその関数を介して出力されたデータからデータを呼び出そうとするまでうまく動作します。別の関数で、私はコンテンツウィッヒから関数を呼び出すことはできませんなぜajaxから呼び出されたphpが複数の呼び出しで動作しない
$(function() {
$(".article_edit").click(function() {
var article_id = $(this).attr("id");
var dataString = 'article_id='+article_id;
//$('a#'+article_id).removeClass('liked');
$('#post-body-'+article_id).fadeOut("slow").html('<img src="images/loader.gif" class="loading" />');
$('a#'+article_id).html('<img src="images/loader.gif" class="loading" />');
$.ajax({
\t type: "POST",
\t url: "action/article_enable_edit.php",
\t data: dataString,
\t cache: false,
\t success: function(data){
if (data == 0) {
\t alert('Actiunea nu a putut fi realizata!');
\t } else {
\t $('#post-body-'+article_id).fadeIn("slow").html(data);
\t }
\t }
});
return false;
});
});
$(function() {
$(".article_edit_close").click(function() {
var article_id = $(this).attr("id");
var dataString = 'article_id='+article_id;
//$('a#'+article_id).removeClass('liked');
$('#post-body-'+article_id).fadeOut("slow").html('<img src="images/loader.gif" class="loading" />');
$('a#'+article_id).html('<img src="images/loader.gif" class="loading" />');
$.ajax({
\t type: "POST",
\t url: "action/article_show.php",
\t data: dataString,
\t cache: false,
\t success: function(data){
if (data == 0) {
\t alert('Actiunea nu a putut fi realizata!');
\t } else {
\t $('#post-body-'+article_id).fadeIn("slow").html(data);
\t }
\t }
});
return false;
});
});
<!-- First button-->
<a class="color-transition article_edit" href="#" id="'.$id.'"><i class="fa fa-pencil-square-o"></i></a>
<!-- When i click it the content will be replaced with another one containing this-->
<!-- output from action/article_enable_edit.php -->
\t \t \t \t <a class="color-transition article_edit_save" href="#" id="'.$id.'" ><i class="fa fa-save"></i></a>
\t \t \t \t <a class="color-transition article_edit_close" href="#" id="'.$id.'" ><i class="fa fa-ban"></i></a>
<!-- Now, if i click on any link, for example: .article_edit_close, the function will not work. -->
<!-- i should have an output from action/article_show.php -->
<!-- If i put these oow links on the index.php page, they worked, but that is not what i need.-->
と呼ばれて:あなたは私のスクリプトをお見せしましょうか?同時に起こることはありません....