내 문제를 heres. 내 코드의 첫 번째 화재가 완벽하게 작동하지만 자바 스크립트 (페이지를 새로 고치는 대신)를 사용하여 제출 단추를 다시로드합니다. 아약스와 관련이없는 모든 것은 두 번째 클릭에서 제대로 실행되지만, 다음 번에 버튼을 클릭하면 아약스가 실행되도록 할 수 없습니다. 여기
$("#edit_company_basic").live('click', function()
{
//get current value of button
var btnText = $("#submit_company_update").val();
//on click the button becomes disabled and value changes to Please Wait
$("#submit_company_update").attr("disabled", true);
$("#submit_company_update").attr("value", "Please wait");
//this one add a loader gif and a updating company message
$('#button_container').append("<div id='update'><center><img id='loading' src='images/icons/ajax-loader (1).gif' /> <font color='red'>Updating company</font></center></div>");
//These variables are used for the ajax datastring
var name = $("#company_name").val();
var bio = $("#company_bio").val();
var forum_url = $("#forum_url").val();
var collection = $("#collection :selected").text();
var fuel = $("#fuel :selected").text();
var repair = $("#repair :selected").text();
var tickets = $("#tickets :selected").text();
var dataString = 'company_name='+ name + '&bio=' + bio + '&forum=' + forum_url + '&collection=' + collection + '&repair=' + repair + '&fuel=' + fuel + '&ticket=' + tickets;
$.ajax({
type: "POST",
url: "library/update_company.php",
data: dataString,
success: function()
{
//On success I give the loader a little more time before anything happens I then re-enable the button allowing the user to be able to click it and give them a message that the copmany has been successfully updated.
setTimeout(function(){$("#submit_company_update").attr("value", btnText); $("#submit_company_update").removeAttr('disabled'); $("#update").html("<center><font color='green'>Company has been updated</font></center>"); }, 1550);
//Here I just give the company updated message a few seconds before I remove it.
setTimeout(function(){$("#update").fadeOut(1000); }, 2200);
}
});
});
이 버튼을 다시 한 번 나는 아약스 실행을 할 수있는 방법 사람이 어떤 아이디어가 있습니까 모든 JScript를
<tr>
<td colspan="2" id="submit_form"><div id="button_container"><center><input type="submit" name="submit_company_update" id="submit_company_update" value="Edit Company" /></center></div></td>
</tr>
을에 관여 내 HTML입니다 : 여기
내 코드입니다 다시 사용할 수 있습니까? 무슨 일이 일어나면 버튼을 다시 클릭하면 에이잭스가 실행되지 않습니다. 사전에감사합니다,
Jefffan24
UPDATE 그래서 여기
해당 페이지에서 내 모든 자바 스크립트 코드 :
<script type="text/javascript">
$(document).ready(function(){
//$("#warning_price").hide();
$(".toggle_container").hide();
//Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state)
$("#company_name").click(function(){
$(".toggle_container").toggleClass("active").slideDown("normal");
});
$("#company_name").blur(function(){
$(".toggle_container").slideUp('normal');
});
//This displays a warning message if they don't have permission to this part of the site.
$("#noperm").html('<div class="ui-widget" style="width:650px; margin:0 auto;"><div class="ui-state-highlight ui-corner-all" style="padding: 0 .7em;"><p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em; margin-top:3px;"></span><strong>Error:</strong><br /> That was a heck of try but you do not have permission to access this area.</p></div></div> ');
//This is a jQuery character count plugin, just setting options and what not
var options2 = {
'maxCharacterSize': 450,
'textFontSize': '12px',
'textColor': '#000000',
'warningColor': '#FF0000',
'originalStyle': 'originalDisplayInfo',
'warningStyle': 'warningDisplayInfo',
'warningNumber': 100,
'displayFormat': '#input Characters | #left Characters Left | #words Words'
};
var options1 = {
'maxCharacterSize': 255,
'textFontSize': '12px',
'textColor': '#000000',
'warningColor': '#FF0000',
'originalStyle': 'originalDisplayInfo',
'warningStyle': 'warningDisplayInfo',
'warningNumber': 40,
'displayFormat': '#input Characters | #left Characters Left | #words Words'
};
$('#company_bio').textareaCount(options2);
$('#company_name').textareaCount(options1);
$('#forum_url').textareaCount(options1);
//End the counter
//Create Select Boxes (using for loops to make 1-50, 1-90, and 1-90 as options
var minimum = 1;
var max_col = 50;
var max_assist = 90;
var i = 1;
var def_collection = <?php echo $collection; ?>;
var def_repair = <?php echo $repair; ?>;
var def_fuel = <?php echo $fuel; ?>;
var def_tickets = <?php echo $ticket; ?>;
//Select boxes for Collection
$("#tdCollection").append("<select id='collection' name='collection'>");
for(i = 1;i <= max_col; i++){
if(i == def_collection){
$("#collection").append("<option selected='selected'>" + i + "</option>");
}
else {
$("#collection").append("<option>" + i + "</option>");
}
}
$("#tdCollection").append("</select>%");
//Select boxes for Repair
$("#tdRepair").append("<select id='repair' name='repair'>");
for(i = 1;i <= max_col; i++){
if(i == def_repair){
$("#repair").append("<option selected='selected'>" + i + "</option>");
}
else {
$("#repair").append("<option>" + i + "</option>");
}
}
$("#tdRepair").append("</select>%");
//Select boxes for Fuel
$("#tdFuel").append("<select id='fuel' name='fuel'>");
for(i = 1;i <= max_col; i++){
if(i == def_fuel){
$("#fuel").append("<option selected='selected'>" + i + "</option>");
}
else {
$("#fuel").append("<option>" + i + "</option>");
}
}
$("#tdFuel").append("</select>%");
//Select boxes for tickets
$("#tdTickets").append("<select id='tickets' name='tickets'>");
for(i = 1;i <= max_col; i++){
if(i == def_tickets){
$("#tickets").append("<option selected='selected'>" + i + "</option>");
}
else {
$("#tickets").append("<option>" + i + "</option>");
}
}
$("#tdTickets").append("</select>%");
//End the select box code.
//On form submit!
$("#edit_company_basic").live('click', function()
{
var btnText = $("#submit_company_update").val();
$("#submit_company_update").attr("disabled", true);
$("#submit_company_update").attr("value", "Please wait");
$('#button_container').append("<div id='update'><center><img id='loading' src='images/icons/ajax-loader (1).gif' /> <font color='red'>Updating company</font></center></div>");
var name = $("#company_name").val();
var bio = $("#company_bio").val();
var forum_url = $("#forum_url").val();
var collection = $("#collection :selected").text();
var fuel = $("#fuel :selected").text();
var repair = $("#repair :selected").text();
var tickets = $("#tickets :selected").text();
var dataString = 'company_name='+ name + '&bio=' + bio + '&forum=' + forum_url + '&collection=' + collection + '&repair=' + repair + '&fuel=' + fuel + '&ticket=' + tickets;
$.ajax({
type: "POST",
url: "library/update_company.php",
data: dataString,
success: function()
{
setTimeout(function(){$("#submit_company_update").attr("value", btnText); $("#submit_company_update").removeAttr('disabled'); $("#update").html("<center><font color='green'>Company has been updated</font></center>"); }, 1550);
setTimeout(function(){$("#update").fadeOut(1000); }, 2200);
}
});
});
});
</script>
가 그리고 여기에 내 모든 HTML
<form method="post" action="" name="edit_company_basic" id="edit_company_basic">
<table class="company" cellspacing="0" cellpadding="7" style="width:550px; margin:0 auto;">
<!--<tr>
<td colspan="4" style="padding:0px;"><img src="<?php echo $image; ?>" alt="<?php echo $name; ?> Logo" /></td>
</tr>-->
<tr>
<th colspan="2" class="th_bold"><center>Basic Information</center></th>
</tr>
<tr>
<th width="120">Company Name:</th>
<td width="400" valign="top"><input type="text" name="company_name" class="company_name" id="company_name" value="<?php echo $name; ?>" style="width:395px;" /><br />
<div class="toggle_container">
<div class="block">
<span id="warning_price" style="background:#FFF9F9; border:1px solid red; min-width:395px; width:395px; padding:5px;"><strong>Warning:</strong> Editing the name will cost the company $2000</span>
</div>
</div>
</td>
</tr>
<tr>
<th valign="top">Company Bio:</th>
<td width="400"><textarea name="company_bio" id="company_bio" style="width:390px; margin:0 auto; padding:5px; height:150px;"><?php echo $bio; ?></textarea></td>
</tr>
<tr>
<th>Forum URL:</th>
<td><input type="text" name="forum_url" id="forum_url" value="<?php echo $forum; ?>" style="width:395px;" /></td>
</tr>
<tr>
<th>Default Collection:</th>
<td id="tdCollection"></td>
</tr>
<tr>
<th>Default Repair Assistance:</th>
<td id="tdRepair"></td>
</tr>
<tr>
<th>Default Fuel Assistance:</th>
<td id="tdFuel"></td>
</tr>
<tr>
<th>Default Ticket Assistance:</th>
<td id="tdTickets"></td>
</tr>
<tr>
<td colspan="2" id="submit_form"><div id="button_container"><center><input type="submit" name="submit_company_update" id="submit_company_update" value="Edit Company" /></center></div></td>
</tr>
</table>
</form>
누군가가 나를 알게되면, 거기에 몇 가지 PHP가 있지만 그 중 아무도 내가 사용하는 관광 명소가 어떤 문제를 일으키지 않는 것으로 믿지 않는 문제가 없습니다. 귀하의 "클릭"처리기가 false
을 반환해야
'나는 긴 검색된 '태그, 장기. – Pointy
롤 예, 내가 빨리 글꼴을 사용하는 대신 CSS를 바꿀 필요가있을 때. – jefffan24
원하는 요소에 항상'style = "color : red"'를 사용할 수 있습니다. – Pointy