此Div消息正在更改并在Firefox中显示,但它未显示在chrome中。
这是HTML:
<div style="position: relative; color: Green" id="divMessage">
<input type="button" value="value" class="abc" id="btnClick" name="Submit" />
使用Javascript:
var strMessageEmpty = "";
var strMessageSavingInProgress = "Saving Data. Please wait...";
var strMessageDone = "Module Calculation has been done...!";
$("#btnClick").click(function() {
$("#divMessage").val(strMessageEmpty);
$("#divMessage").html(strMessageSavingInProgress);
// SAVE DATA
$.ajax({
type: 'post',
// contentType: 'application/json',
async: false,
cache: false,
url: '/Controller/Action',
// dataType: 'json',
data: {
Period: $('#ddlPeriod').val()
},
success: function(data) {
$("#divMessage").html(strMessageSavingInProgress);
key = data;
},
error: function(err) {}
$("#divMessage").val(strMessageEmpty);
});
答案 0 :(得分:0)
我相信$(“#divMessage”)。val(strMessageEmpty);应该放在$ .ajax调用之外(或者你可能想把它放在别处,但它的当前放置是不对的):
$.ajax({
type: 'post',
// contentType: 'application/json',
async: false,
cache: false,
url: '/Controller/Action',
// dataType: 'json',
data: {
Period: $('#ddlPeriod').val()
},
success: function (data) {
$("#divMessage").html(strMessageSavingInProgress);
key = data;
}, error: function (err) {
}
});
$("#divMessage").val(strMessageEmpty);
更新:正如其他人指出的那样,您需要正确关闭div标签,如下所示:
<div style="position: relative; color: Green" id="divMessage"></div>