많은 텍스트 상자가있는 페이지가 있습니다. 각 텍스트 상자에는 구분 된 ID와 제출 버튼이 있습니다. 사용자가 텍스트 상자를 변경하고 제출 버튼을 클릭하면 해당 텍스트 상자를 ajax로 업데이트합니다. (이 아약스 프로세스 버튼이 사라지고 텍스트 박스가 비활성화되었습니다 .. 그리고로드 GIF가 나타납니다.) 이제 문제는 : 사용자가 첫 번째 텍스트 상자를 변경하고 제출 버튼을 클릭하면 모든 것이 완벽하게 작동합니다! 사용자가 두 번째 버튼을 클릭하면 두 버튼이 모두 사라졌습니다 !! 계속 업데이트하면 모든 버튼이 사라지고 나타납니다 !! 내 코드는 다음과 같습니다
<script type="text/javascript">
function iajax(obj)
{(function($){ //jQuery GAURD
var p = obj.getAttribute('id',2);
var itemid = p.substring(6); // find btn id
var val = $("#txtTags"+itemid).val();
$("#tagsup"+itemid).ajaxStart(function(){
$("#tagsup"+itemid).hide();
$("#msg"+itemid).empty().html("<img src='./images/admin_uploading.gif'/>");
$("#txtTags"+itemid).attr("disabled","disabled");
});
$("#msg"+itemid).ajaxSuccess(function(){
$(this).remove(":first").html("<span>Success..</span>").fadeOut(5000); // remove loading image
});
$("#tagsup"+itemid).ajaxComplete(function(){
$("#tagsup"+itemid).show(); // show submit btn
$("#txtTags"+itemid).removeAttr("disabled"); // Enable txt
});
$.ajax({
type: "post",
url: "proc.php",
data: "val="+ val,
async:false,
cache: false,
Error: function(){ $("#msg"+itemid).append("<span>Failed!</span>").fadeOut(5000); }
});
return false;
}) (jQuery);
}
</script>
몸이 같다 :
<div>
<input type="text" id="txtTags7332" width="200px" />
<input type="button" onclick="iajax(this)" value="up" class="button" id="tagsup7332" />
<div id="msg7332" style="float:left"></div>
</div>
당신이 나를 도울 수 .. 어디에 문제가!?