Php 使用jquery加载数据时,在短延迟内显示加载png
我正试图在很短的时间内显示一个loading.png图形来完成我的查询e.t.c以下所有内容目前都运行良好。我只需要在td中获得图形加载。只有在输入产品代码并正在检查时才可用 有什么想法吗 这是我的JSPhp 使用jquery加载数据时,在短延迟内显示加载png,php,jquery,Php,Jquery,我正试图在很短的时间内显示一个loading.png图形来完成我的查询e.t.c以下所有内容目前都运行良好。我只需要在td中获得图形加载。只有在输入产品代码并正在检查时才可用 有什么想法吗 这是我的JS $("#prodcodecheck").blur(function() { var $this = $(this); $this .closest('tr') // find the parent tr .find(
$("#prodcodecheck").blur(function() {
var $this = $(this);
$this
.closest('tr') // find the parent tr
.find('td.available') // find the imgsample in the row
.html( $(this).attr('id')) // update the contents
//.animate({'opacity':1},200);
var available = $this.closest('tr').find('td.available')
$.post('checkstock.php', //this page reads the image code and gives you the image location
{ action: 'searchimage', productcode: $(this).val() },
function(data) {available.html(data);}
);
});
这里是checkstock.php
//Find Stock Value
function checkstock($prodCode) {
$prodCode = strtoupper($prodCode);
require '../../../../config.php';
$dbh = new PDO(DB_DSN, DB_USER, DB_PASS);
$sql = "SELECT * FROM isproducts WHERE prodCode = '".$prodCode."'";
$stmt = $dbh->query($sql);
$obj = $stmt->fetch(PDO::FETCH_OBJ);
$count = $stmt->rowCount();
echo ($count == 1 ? 'The current stock value of item '.$obj->prodCode.' is '.ROUND($obj->FreeStockQuantity, 0).'' : 'Invalid product code');
}
//Call Stock Function
checkstock($_POST['productcode']);
一个简单的方法是:
...
// reveal a 'loading' div/span or whatever right before the request
$("#loading").show();
$.post('checkstock.php', { action: 'searchimage', productcode: $(this).val() },
function(data) {
available.html(data);
// hide it again once the request has completed
$("#loading").hide();
}
);
一个简单的方法是:
...
// reveal a 'loading' div/span or whatever right before the request
$("#loading").show();
$.post('checkstock.php', { action: 'searchimage', productcode: $(this).val() },
function(data) {
available.html(data);
// hide it again once the request has completed
$("#loading").hide();
}
);
创建一个jQuery选择器,其中包含加载的img,并在ajax代码之前将其附加到td
var loadingImg = $('<img src="/assets/images/loading.gif">');
available.append(loadingImg);
var loadingImg=$('');
可用。追加(加载img);
创建一个jQuery选择器,其中包含加载的img,并在ajax代码之前将其附加到td
var loadingImg = $('<img src="/assets/images/loading.gif">');
available.append(loadingImg);
var loadingImg=$('');
可用。追加(加载img);
为什么不使用Jquery load或ajax?
在启动load函数之前,将加载图像放入其中。为什么不使用Jquery load或ajax? 在启动加载功能之前,将加载图像放在内部