如何通过json处理客户端的警报消息? [英] How can I handle alert messages in client side by json ?

查看:89
本文介绍了如何通过json处理客户端的警报消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

function chkProjectCode(checkBox){

if(document.getElementById('<%= hdnCheckedPrevious.ClientID%>')。value ==){

if(checkBox.checked){

document.getElementById('<%= hdnCheckedPrevious.ClientID%>')。value = document.getElementById(checkBox.id.replace('chkInvoices') ,'lblProjectCode'))。innerHTML;

}

}

 



else {

if(document.getElementById('<%= hdnCheckedPrevious.ClientID%>')。value!= document.getElementById(checkBox.id.replace('chkInvoices') ,'lblProjectCode'))。innerHTML){

checkBox.checked = false;

alert('请选择具有相同项目代码的发票。');

返回false;

}

}

}





在上面的代码中,我显示警告信息'请选择具有相同项目代码的发票。'。现在我想清除所有硬编码的消息到json格式。那么这将是更好的方式在asp .net中使用。



我尝试过:



在服务器端,我已经完成了json格式。我在客户端的警报消息上遇到问题。请帮忙。

解决方案

引用:

在服务器端我已经完成了json格式。





我不确定你的目标究竟是什么,你想要在警报功能中显示JSON结果。



为了从服务器获取数据。您需要发出一个AJAX请求,该请求将以JSON格式的形式吐出数据:使用jQuery AJAX和ASP.NET与数据库进行通信的许多方法 [ ^ ]


function chkProjectCode(checkBox) {
if (document.getElementById('<%= hdnCheckedPrevious.ClientID %>').value == "") {
if (checkBox.checked) {
document.getElementById('<%= hdnCheckedPrevious.ClientID %>').value = document.getElementById(checkBox.id.replace('chkInvoices', 'lblProjectCode')).innerHTML;
}
}


else {
if (document.getElementById('<%= hdnCheckedPrevious.ClientID %>').value != document.getElementById(checkBox.id.replace('chkInvoices', 'lblProjectCode')).innerHTML) {
checkBox.checked = false;
alert('Please select Invoices with same Project Code.');
return false;
}
}
}


In above code i am showing alert message 'Please select Invoices with same Project Code.'. now I want to clear all hard coded messages to json format. So which will be better way to use in asp .net.

What I have tried:

In server side i have already done with json format. I am facing problem on the alert message on client side. Please help.

解决方案

Quote:

In server side i have already done with json format.



I'm not sure what exactly is your goal why you would want to display a JSON result in an alert function.

In order for you to get the data from your server. You would need to issue an AJAX request that would spit out a data in form of JSON format: Many ways to communicate with your database using jQuery AJAX and ASP.NET[^]


这篇关于如何通过json处理客户端的警报消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆