个人笔记~~~~~~~~~~~~~~~
POST方式异步刷新传数据的方法(常用于 编辑 添加页面)
-
<script>
-
-
function mysqlping() {
-
var $host = $("#dbname").val();
-
var $port = $("#dport").val();
-
var $eserver = $("#eserver").val();
-
$.ajax({
-
type:'post',
-
url:'/eproject/edatabase/add/',
-
data:{a:$host,b:$port,c:$eserver},
-
dataType:"json",
-
success:function(msg){
-
if (msg.status)
-
{
-
swal({
-
icon: "success",
-
text: "SSH连接成功!",
-
});
-
}
-
else
-
{
-
swal({
-
icon: "error",
-
text: "SSH连接失败!",
-
});
-
}
-
}
-
-
-
-
});
-
-
}
-
</script>
views层获取数据的方法
-
if request.is_ajax():
-
dbname=request.POST.get('a')
-
dport=request.POST.get('b')
-
print '8888888888888',dbname,dport
GET方式异步刷新传数据的方法(常用于 list展示页面)
-
function cheshi{{ release.id }}()
-
{
-
$.getJSON('/serman/release/list/',{'a':{{ release.id }},'b':{{ release.status }} },function(ret){
-
// 填入数据
-
if (ret.status == '0'){
-
swal({
-
icon: "error",
-
text: "发布中,请不要重复发布!",
-
});
-
else {
-
swal({
-
icon: "error",
-
text: "未知错误!",
-
});
-
-
window.open('{% url 'release_list' %}', "_self");
-
-
}
-
-
-
})
-
-
}
views层获取数据的方法
-
if request.is_ajax():
-
ret = {}
-
delid=request.GET.get('a','')
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29096438/viewspace-2150167/
,如需转载,请注明出处,否则将追究法律责任。