它停在.done()代码中的任何位置。有时它在我清理缓存后运行良好,或者我必须刷新几次才能完成表单填充。 这些代码在我的javascript文件和我的php文件中。
$(function() {
$.ajaxSetup({
cache: false
});
function getData(id) {
$.getJSON('process.php', {
action: "lookup",
id: id
})
.done(function(data) {
if (data.id > 0) {
$('#txtaction').val('update');
$('#txtaction2').val('new');
$('#txtaction3').val('new');
$('#txtaction4').val('new');
$('#txtaction_ex_cost').val('new_cost');
$('#txtaction_im_cost').val('new_cost');
$('#txtjob_id').val(data.id);
$('#txtjob_id2').val(data.id);
$('#txtjob_id3').val(data.id);
$('#txtjob_id4').val(data.id);
$('#txtjob_id_ex_cost').val(data.id);
$('#txtjob_ref').val(data.job_ref);
$('#txtbranch').val(data.branch);
$.getJSON('process.php?action=getUserBranch', function(branch_data) {
if (branch_data == "") {
// HQ : enable select
$('label[for="txtbranch"]').show();
$('#txtbranch').show();
} else {
// disable select
$('label[for="txtbranch"]').hide();
$('#txtbranch').hide();
}
});
$('#txttradelane').val(data.tradelane);
$('#txtshipment_type').val(data.shipment_type);
if (data.shipment_type == "EX") document.getElementById('lbl_txtport').innerHTML = "<b>POL Code</b>";
else document.getElementById('lbl_txtport').innerHTML = "<b>POD Code</b>";
$('#txtcompany').val(data.company);
$('#txtstatus').val(data.status);
$('#txtdata_status').val(data.status);
$('#txtmode').val(data.mode);
$('#txtport').val(data.port_code);
$('#txtport_name').val(data.port_name + ', ' + data.country_name);
$('#txtvessel').val(data.vessel_code);
$('#txtvessel_name').val(data.vessel_name);
$('#txtvoyage_no').val(data.voyage_no);
$('#txtclosing_datetime').val(data.closing_datetime);
$('#txtport_vessel_code').val(data.port_vessel_code);
$('#txtsa').val(data.sa_code);
$('#txtsa_name').val(data.sa_name);
$('#txtpsa').val(data.psa_code);
$('#txtpsa_name').val(data.psa_name);
$('#txtscn').val(data.scn);
$('#txtka_no').val(data.ka_no);
$('#txtopr_code').val(data.opr_code);
if (data.nil_manifest == 1)
$('#txtnil_manifest').prop('checked', true);
else
$('#txtnil_manifest').prop('checked', false);
if (data.shipment_type == "EX") {
//document.getElementById('lbl_txtport').innerHTML = "<b>POL Code</b> (Type name/code to search)";
//document.getElementById('lbl_txtport_name').innerHTML = "<b>POL Name</b>";
$('#txtpol_code').attr("readonly", true);
$("#txtpol_code").addClass("readonly");
$('#txtpod_code').attr("readonly", false);
$("#txtpod_code").removeClass("readonly");
$('#txtpol_code').val(data.port_code);
$('#txtpol_name').val(data.port_name + ', ' + data.country_name);
$('#txtpod_code').val("");
$('#txtpod_name').val("");
$("select#txtpod_terminal").html("");
$("select#txtpod_terminal").removeClass("text");
$("select#txtpod_terminal").addClass("text");
} else {
if (data.shipment_type == "IM") {
//document.getElementById('lbl_txtport').innerHTML = "<b>POD Code</b> (Type name/code to search)";
//document.getElementById('lbl_txtport_name').innerHTML = "<b>POD Name</b>";
$('#txtpol_code').attr("readonly", false);
$("#txtpol_code").removeClass("readonly");
$('#txtpod_code').attr("readonly", true);
$("#txtpod_code").addClass("readonly");
$('#txtpol_code').val("");
$('#txtpol_name').val("");
$('#txtpod_code').val(data.port_code);
$('#txtpod_name').val(data.port_name + ', ' + data.country_name);
$("select#txtpol_terminal").html("");
$("select#txtpol_terminal").removeClass("text");
$("select#txtpol_terminal").addClass("text");
}
}
var options = '<option value=""> </option>';
$.getJSON('../../search/terminalByPort.php', {
port: data.port_code
}, function(data) {
for (var i = 0; i < data.length; i++) {
options += '<option value="' + data[i].label + '">' + data[i].value + '</option>';
}
if ($("#txtshipment_type").val() == "EX") {
$("select#txtpol_terminal").html(options);
$("select#txtpol_terminal").removeClass("text");
$("select#txtpol_terminal").addClass("text");
} else {
$("select#txtpod_terminal").html(options);
$("select#txtpod_terminal").removeClass("text");
$("select#txtpod_terminal").addClass("text");
}
});
$('#pol_list').load('pol_list.php?job_id=' + data.id);
$('#pod_list').load('pod_list.php?job_id=' + data.id);
$('#ts_list').load('ts_list.php?job_id=' + data.id);
if (data.shipment_type == 'EX' && data.job_ref != "") {
$('#tabs ul > li:eq(1)').show();
$('#tabs ul > li:eq(2)').show();
$('#tabs ul > li:eq(3)').show();
$('#tabs ul > li:eq(4)').show();
$('#tabs ul > li:eq(5)').show();
$('#tabs ul > li:eq(6)').hide();
$('#tabs ul > li:eq(7)').hide();
$('#tabs ul > li:eq(8)').hide();
$('#tabs ul > li:eq(9)').hide();
$('#tabs ul > li:eq(10)').show();
$('#tabs ul > li:eq(11)').hide();
} else {
if (data.shipment_type == 'IM' && data.job_ref != "") {
$('#tabs ul > li:eq(1)').hide();
$('#tabs ul > li:eq(2)').hide();
$('#tabs ul > li:eq(3)').hide();
$('#tabs ul > li:eq(4)').hide();
$('#tabs ul > li:eq(5)').hide();
$('#tabs ul > li:eq(6)').show();
$('#tabs ul > li:eq(7)').show();
$('#tabs ul > li:eq(8)').show();
$('#tabs ul > li:eq(9)').show();
$('#tabs ul > li:eq(10)').hide();
$('#tabs ul > li:eq(11)').show();
} else {
$('#tabs ul > li:eq(1)').hide();
$('#tabs ul > li:eq(2)').hide();
$('#tabs ul > li:eq(3)').hide();
$('#tabs ul > li:eq(4)').hide();
$('#tabs ul > li:eq(5)').hide();
$('#tabs ul > li:eq(6)').hide();
$('#tabs ul > li:eq(7)').hide();
$('#tabs ul > li:eq(8)').hide();
$('#tabs ul > li:eq(9)').hide();
$('#tabs ul > li:eq(10)').hide();
$('#tabs ul > li:eq(11)').hide();
}
}
if (data.status == "OPEN") {
if (data.job_ref == "") {
$("#formdiv :input").attr("disabled", false);
} else {
$("#formdiv :input").attr("disabled", false);
$("#txtshipment_type").attr("disabled", true);
$("#txttradelane").attr("disabled", true);
$("#txtmode").attr("disabled", true);
$("#txtport").attr("disabled", true);
}
$("#txtvessel_code").select().focus();
} else {
if (data.status == "CANCELED") {
$("#formdiv :input").attr("disabled", true);
} else {
if (data.status == "CONFIRMED") {
$("#formdiv :input").attr("disabled", true);
}
}
}
$('#txtaction').attr("disabled", false);
$('#txtaction2').attr("disabled", false);
$('#txtaction3').attr("disabled", false);
$('#txtaction4').attr("disabled", false);
$('#txtstatus').attr("disabled", false);
$('#txtdata_status').attr("disabled", false);
$('#txtjob_id').attr("disabled", false);
$('#txtjob_id2').attr("disabled", false);
$('#txtjob_id3').attr("disabled", false);
$('#txtjob_id4').attr("disabled", false);
$('#txtjob_pol_id').attr("disabled", false);
$('#txtjob_pod_id').attr("disabled", false);
$('#txtsa_name').attr("disabled", false);
$('#txtpsa_name').attr("disabled", false);
$('#btn_save2').attr("disabled", false);
$("#booking :input").attr("disabled", false);
$("#cmo :input").attr("disabled", false);
$("#bl :input").attr("disabled", false);
$("#bl_billing :input").attr("disabled", false);
$("#bl_container :input").attr("disabled", false);
$("#do_container :input").attr("disabled", false);
$("#do :input").attr("disabled", false);
$("#do_billing :input").attr("disabled", false);
$("#do_equip_billing :input").attr("disabled", false);
$("#btn_edit_ex_cost").attr("disabled", false);
$("#btn_edit_im_cost").attr("disabled", false);
$('#btn_delete').attr('disabled', false);
}
});
}
<form id="form1" method="post" name="form1">
<div class="sixper">
<label for="txtaction">Action
<input type="text" name="txtaction" id="txtaction" class="text readonly" ReadOnly>
</label>
<input type="hidden" name="txtjob_id" id="txtjob_id" class="text readonly" ReadOnly>
<label for="txtjob_ref">Job Ref
<input type="text" name="txtjob_ref" id="txtjob_ref" maxlength="15" class="text readonly" Readonly />
</label>
<label for="txtopr_code">Operator Code
<input type="text" name="txtopr_code" id="txtopr_code" class="text readonly" Readonly />
</label>
<label for="txtcompany">Company
<input type="text" name="txtcompany" id="txtcompany" class="text readonly" Readonly />
</label>
<label for="txtbranch">Branch
<select name="txtbranch" id="txtbranch">
<?php try { $dbh=D atabaseHelpers::getDatabaseConnection(); $stmt=$ dbh->prepare('SELECT * ' . 'FROM branch ' . 'ORDER BY branch_name'); $success = $stmt->execute(); if ($success) { while ($branch_result = $stmt->fetch()){ printf ("
<option value='%s'>%s</option>",$branch_result['branch_code'], $branch_result['branch_name']); } } $dbh = null; } catch (PDOException $e) { echo $e->getMessage(); } ?>
</select>
</label>
</div>
<div class="spacer"></div>
<div class="sixper">
<label for="txtmode">Shipment Mode
<select NAME='txtmode' id="txtmode" title="Shipment Mode" class="text">
<?php try { $dbh=D atabaseHelpers::getDatabaseConnection(); $stmt=$ dbh->prepare('SELECT distinct(bt_type) ' . 'FROM book_type ' . 'ORDER BY bt_type'); $success = $stmt->execute(); if ($success) { while ($booking_type_result = $stmt->fetch()){ printf ("
<option value='%s'>%s</option>",$booking_type_result['bt_type'], $booking_type_result['bt_type']); } } $dbh = null; } catch (PDOException $e) { echo $e->getMessage(); } ?>
</select>
</label>
<label for="txtshipment_type">Shipment Type
<select NAME='txtshipment_type' id="txtshipment_type" title="Import / Export" class="text">
<option value="EX">EXPORT</option>
<option value="IM">IMPORT</option>
</select>
</label>
<label for="txtport"><span id="lbl_txtport">POL Code</span>
<input type="text" name="txtport" id="txtport" maxlength="10" class="text" />
</label>
<label for="txtport_name">Port Name
<input type="text" name="txtport_name" id="txtport_name" class="text readonly" Readonly />
</label>
<label for="txttradelane">Tradelane
<select NAME='txttradelane' id="txttradelane" title="Tradelane" class="text">
<option value=''> </option>
<?php try { $dbh=D atabaseHelpers::getDatabaseConnection(); $stmt=$ dbh->prepare('SELECT * ' . 'FROM tradelane ' . 'ORDER BY tradelane_name'); $success = $stmt->execute(); if ($success) { while ($tradelane_result = $stmt->fetch()){ printf ("
<option value='%s'>%s</option>",$tradelane_result['tradelane_abbrev'], $tradelane_result['tradelane_name']); } } $dbh = null; } catch (PDOException $e) { echo $e->getMessage(); } ?>
</select>
</label>
<label for="txtstatus">Status
<select NAME='txtstatus' id="txtstatus" title="Job Status" class="text">
<option value="OPEN">OPEN</option>
<option value="CONFIRMED">CONFIRMED</option>
<option value="CANCELED">CANCELED</option>
</select>
<input type="hidden" name="txtdata_status" id="txtdata_status">
</label>
</div>
<div class="spacer"></div>
<div class="spacer"></div>
<br clear="LEFT">
<ul>
<li><a href="#job_info">Job Info</a>
</li>
<li><a href="#booking" class="booking_list">Booking</a>
</li>
<li><a href="#cmo" class="cmo_list">CMO</a>
</li>
<li><a href="#bl" class="bl_list">Bill of Lading</a>
</li>
<li><a href="#bl_billing" class="bl_billing_list">Billing</a>
</li>
<li><a href="#bl_container" class="bl_container_list">Container Movement</a>
</li>
<li><a href="#do" class="do_list">Delivery Order</a>
</li>
<li><a href="#do_billing" class="do_billing_list">Billing</a>
</li>
<li><a href="#do_equip_billing" class="equip_billing_list">Equipment Billing</a>
</li>
<li><a href="#do_container" class="do_container_list">Container Movement</a>
</li>
<li><a href="#ex_costing" class="ex_costing_list">Costing</a>
</li>
<li><a href="#im_costing" class="im_costing_list">Costing</a>
</li>
</ul>
<DIV class="ui-layout-content ui-widget-content" style="width:100%;height:470px;overflow-x: hidden !important; ">
<div id="job_info">
<div class="fourper">
<label for="txtvessel">Vessel / Flight Code
<input type="text" name="txtvessel" id="txtvessel" class="text" placeholder="Type & Select" />
</label>
<label for="txtvessel_name">Vessel / Flight Name
<input type="text" name="txtvessel_name" id="txtvessel_name" class="text readonly" READONLY />
</label>
<label for="txtvoyage_no">Voyage / Flight No
<input type="text" name="txtvoyage_no" id="txtvoyage_no" maxlength="10" class="text" />
</label>
<label for="txtport_vessel_code">Port Vessel Code
<input type="text" name="txtport_vessel_code" id="txtport_vessel_code" maxlength="5" class="text readonly" READONLY />
</label>
</div>
<div class="spacer"></div>
<div class="fourper">
<label for="txtpsa">Principal Shipping Agent Code
<input type="text" name="txtpsa" id="txtpsa" class="text" placeholder="Type & Select" />
</label>
<label for="txtpsa_name">Principal Agent Name
<input type="text" name="txtpsa_name" id="txtpsa_name" class="text readonly" READONLY />
</label>
<label for="txtsa">Shipping Agent Code
<input type="text" name="txtsa" id="txtsa" class="text" placeholder="Type & Select" />
</label>
<label for="txtsa_name">Shipping Agent Name
<input type="text" name="txtsa_name" id="txtsa_name" class="text readonly" READONLY />
</label>
</div>
<div class="spacer"></div>
<div class="fourper">
<label for="txtclosing_datetime">Closing Date Time
<input type="text" name="txtclosing_datetime" id="txtclosing_datetime" maxlength="25" class="text" />
</label>
<label for="txtscn">SCN
<input type="text" name="txtscn" id="txtscn" maxlength="10" class="text" />
</label>
<label for="txtka_no">KA No.
<input type="text" name="txtka_no" id="txtka_no" maxlength="10" class="text" />
</label>
<label for="txtnil_manifest">
<br>
<input type="checkbox" name="txtnil_manifest" id="txtnil_manifest" value="1" /> Nil Manifest <i>(EDI Purpose)</i>
</label>
</div>
<div class="spacer"></div>
<br clear="LEFT">
<br clear="LEFT">
<span class="sub-section">Please save before proceeding to next section</span>
<div class="oneper">
<p align="center">
<button type="button" class="button" id="btn_save2" name="btn_save2" Title="Save" style="cursor:pointer;border:none;padding: 5px;margin:2px;">
<img src="../../images/icon/save2.gif" alt="Save">
<br>Click to save data above
</button>
</p>
</div>
<div class="spacer"></div>
<br clear="LEFT">
<br clear="LEFT">
</form>
<span class="section">POL Terminal</span>
<!-- ******************************************************************* -->
<!-- Comment************************************************************ -->
<!-- ***************** PORT VESSEL ID ********************************** -->
<!-- ******************************************************************* -->
<!-- ******************************************************************* -->
<form method="post" name="form2_1" id="form2_1">
<div class="fourper">
<label for="txtaction2">Action
<input type="text" name="txtaction2" id="txtaction2" class="text readonly" ReadOnly>
</label>
<label for="txtjob_id2">Job ID
<input type="text" name="txtjob_id2" id="txtjob_id2" class="text readonly" ReadOnly>
</label>
<label for="txtjob_pol_id">Job POL ID
<input type="text" name="txtjob_pol_id" id="txtjob_pol_id" class="text readonly" ReadOnly>
</label>
</div>
<div class="spacer"></div>
<div class="fourper">
<label for="txtpol_code">POL Code
<input type="text" name="txtpol_code" id="txtpol_code" maxlength="10" class="text" placeholder="Type & Select" />
</label>
<label for="txtpol_name">POL NAME
<input type="text" name="txtpol_name" id="txtpol_name" class="text readonly" Readonly />
</label>
</div>
<div class="spacer"></div>
<div class="fourper">
<label for="txtpol_terminal">Terminal
<select NAME='txtpol_terminal' id="txtpol_terminal" title="POL Terminal">
</select>
</label>
<label for="txteta_pol">ETA POL
<input type="text" name="txteta_pol" id="txteta_pol" maxlength="12" class="text" />
</label>
<label for="txtetd_pol">ETD POL
<input type="text" name="txtetd_pol" id="txtetd_pol" maxlength="12" class="text" />
</label>
</div>
<div class="spacer"></div>
<div class="oneper">
<p align="center">
<button type="button" name="btn_save_pol" id="btn_save_pol" title="Save POL" class="cssbutton">
<img src="../../images/icon/save.gif" alt="Save">Save POL
</button>
</p>
</div>
<div class="spacer"></div>
<br clear="LEFT">
<br clear="LEFT">
<div id="pol_list"></div>
<div class="spacer"></div>
<br clear="LEFT">
<br clear="LEFT">
</form>
<span class="section">POD Terminal</span>
<!-- ******************************************************************* -->
<!-- Comment************************************************************ -->
<!-- ***************** POD & Terminal ********************************** -->
<!-- ******************************************************************* -->
<!-- ******************************************************************* -->
<form method="post" name="form2_2" id="form2_2">
<div class="fourper">
<label for="txtaction3">Action
<input type="text" name="txtaction3" id="txtaction3" class="text readonly" ReadOnly>
</label>
<label for="txtjob_id3">Job ID
<input type="text" name="txtjob_id3" id="txtjob_id3" class="text readonly" ReadOnly>
</label>
<label for="txtjob_pod_id">Job POD ID
<input type="text" name="txtjob_pod_id" id="txtjob_pod_id" class="text readonly" ReadOnly>
</label>
</div>
<div class="spacer"></div>
<div class="fourper">
<label for="txtpod_code">POD Code
<input type="text" name="txtpod_code" id="txtpod_code" maxlength="10" class="text" placeholder="Type & Select" />
</label>
<label for="txtpod_name">POD NAME
<input type="text" name="txtpod_name" id="txtpod_name" class="text readonly" Readonly />
</label>
</div>
<div class="spacer"></div>
<div class="fourper">
<label for="txtpod_terminal">POD Terminal
<select NAME='txtpod_terminal' id="txtpod_terminal" title="POD Terminal">
</select>
</label>
<label for="txteta_pod">ETA POD
<input type="text" name="txteta_pod" id="txteta_pod" maxlength="12" class="text" />
</label>
<label for="txtetd_pod">ETD POD
<input type="text" name="txtetd_pod" id="txtetd_pod" maxlength="12" class="text" />
</label>
</div>
<div class="spacer"></div>
<div class="oneper">
<p align="center">
<button type="button" name="btn_save_pod" id="btn_save_pod" title="Save POD" class="cssbutton">
<img src="../../images/icon/save.gif" alt="Save">Save POD
</button>
</p>
</div>
<div class="spacer"></div>
<br clear="LEFT">
<br clear="LEFT">
<div id="pod_list"></div>
<div class="spacer"></div>
<br clear="LEFT">
<br clear="LEFT">
</form>
<span class="section">Transhipment Terminal</span>
<!-- ******************************************************************* -->
<!-- Comment************************************************************ -->
<!-- ***************** TRANSHIPMENT & Terminal ************************* -->
<!-- ******************************************************************* -->
<!-- ******************************************************************* -->
<form method="post" name="form2_3" id="form2_3">
<div class="fourper">
<label for="txtaction4">Action
<input type="text" name="txtaction4" id="txtaction4" class="text readonly" ReadOnly>
</label>
<label for="txtjob_id4">Job ID
<input type="text" name="txtjob_id4" id="txtjob_id4" class="text readonly" ReadOnly>
</label>
<label for="txtjob_ts_id">Job TS ID
<input type="text" name="txtjob_ts_id" id="txtjob_ts_id" class="text readonly" ReadOnly>
</label>
</div>
<div class="spacer"></div>
<div class="fourper">
<label for="txtts_code">T/S Code
<input type="text" name="txtts_code" id="txtts_code" maxlength="10" class="text" placeholder="Type & Select" />
</label>
<label for="txtts_name">Transhipment Port NAME
<input type="text" name="txtts_name" id="txtts_name" class="text readonly" Readonly />
</label>
</div>
<div class="spacer"></div>
<div class="fourper">
<label for="txtts_terminal">Transhipment Terminal
<select NAME='txtts_terminal' id="txtts_terminal" title="TS Terminal">
</select>
</label>
<label for="txteta_ts">ETA Transhipment Port
<input type="text" name="txteta_ts" id="txteta_ts" maxlength="12" class="text" />
</label>
<label for="txtetd_ts">ETD Transhipment Port
<input type="text" name="txtetd_ts" id="txtetd_ts" maxlength="12" class="text" />
</label>
</div>
<div class="spacer"></div>
<div class="oneper">
<p align="center">
<button type="button" name="btn_save_ts" id="btn_save_ts" title="Save Transhipment" class="cssbutton">
<img src="../../images/icon/save.gif" alt="Save">Save Transhipment Port
</button>
</p>
</div>
<div class="spacer"></div>
<br clear="LEFT">
<br clear="LEFT">
<div id="ts_list"></div>
<div class="spacer"></div>
<br clear="LEFT">
<br clear="LEFT">
</form>
</div>
希望任何人都可以提供帮助。
答案 0 :(得分:0)
首先在脚本中查看这行代码:
$.getJSON('process.php?action=lookup&fixed_item_id='+id, parseInfo);
parseInfo函数调用是否包含了&#39;中的fixed_item_id值的值? &#39; ?如果不 你可能会错过关闭&#39;并且浏览器可能会以您不喜欢的方式对您的网址进行编码。