我在我的网站上使用ajax和jQuery,需要显示进度/加载指示器.
我的困境是这样的:
我似乎找不到任何方法让JS给用户一个正在进行的指示,除了做一个alert().(由于某种原因,警报确实有效).
有什么建议?
我的代码:
JS
var jqXHR = $.ajax(
{
type: "POST",
url: url,
cache: false,
data: params, // array of parameters
async: false, // responseText is empty if set to true
dataType: 'json',
error: function()
{
alert("Ajax post request to the following script failed: " + url);
}
} );
var html = jqXHR.responseText;
Run Code Online (Sandbox Code Playgroud)
PHP
$return = array();
$return['status'] = 1;
$return['message'] = "some html here ...";
echo json_encode($return);
Run Code Online (Sandbox Code Playgroud)