django 前后台 调用关系

django 前后台 调用关系:

node2:/django/mysite/news/templates/cmdb#cat rangeIndex.html
<html>
<head>
	<title>运维平台</title>
	<link rel="stylesheet" type="text/css" href="/static/Css/Equipment/index.css">
	<link rel="stylesheet" type="text/css" href="/static/Css/Public/header.css">
	<link rel="stylesheet" type="text/css" href="/static/Css/Public/menu.css">
</head>
<body>
	<include file="Public:header"/>
	<div class="content">
		<include file="Public:menu"/>
		<div class="con fl">
			<div id="condition">
				<label class="condition">开始IP</label><input type="text" name="condition" class="equipment_sz1">
				<label class="condition">结束IP</label><input type="text" name="condition" class="equipment_sz2">
				<input type="submit" value="IP查询" class="equipment_search_btn es_2">
			</div>
			<table class="gridtable">
				<tr>
					<th>IP </th><th>Info</th><th>ENV</th>
				</tr>
			</table>
		</div>
	</div>
</body>
<script type="text/javascript" src="/static/Js/jquery-2.2.2.min.js"></script>
<script type="text/javascript" src="/static/Js/Equipment/rangeIndex.js"></script> 
<!-- <script type="text/javascript" src="/static/Js/Public/ajax.js"></script> -->
</html>


node2:/django/mysite/static/Js/Equipment#cat rangeIndex.js 
?$(function(){
	
	var _env_bt = $(".content .con #condition .es_2");
	
	_env_bt.on('click',function(){
		var __range_start = $(".equipment_sz1").val();
		var __range_stop = $(".equipment_sz2").val();
                console.log(__range_start);
                console.log(__range_stop);
		var data={};
                data.start = __range_start;
		data.stop = __range_stop;
		var successfn = function(jdata){
                    $(".gridtable").empty();
					var _HTML="<tr><th>IP </th><th>Info</th><th>ENV</th></tr>";
					$.each(jdata,function(i,val){
						_HTML=_HTML+"<tr><td>"+jdata[i].ip+"</td><td>"+jdata[i].info+"</td><td>"+jdata[i].env+"</td></tr>";
					});
					$(".gridtable").html(_HTML);
                };
		var errorfn = function(){
                    alert("数据获取出错");
                };
	$.ajax({
				type: "get",
				data: data,
				url: "/api/ip_range/",
				dataType: "text",
				success: function(d){
					successfn(d);
				},
				error: function(e){
					errorfn(e);
				}
			});
	});
	
});



ajax 调用接口:

url(r'^api/search_group/$', newview.search_group),
url(r'^api/ip_range/$', newview.ip_range),

def rangeIndex(req):
   return render_to_response('cmdb/rangeIndex.html')
本站公众号
   欢迎关注本站公众号,获取更多程序园信息
开发小院