<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <meta charset="UTF-8">
    <th:block th:include="include :: header('网络测试')" />
</head>
<body>
<div class="container-div">
    <form id="fff">
        <div class="form-group">
            <label class="col-sm-3 control-label">请求地址：</label>
            <div class="col-sm-9">
                <input type="text" name="url" class="form-control" placeholder="请输入文本">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">请求方式：</label>
            <div class="col-sm-9">
                <select name="method">
                    <option value="post">
                        post
                    </option>

                    <option value="get">
                        get
                    </option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">参数：</label>
            <div class="col-sm-9">
                <input type="text" name="params" class="form-control" placeholder="请输入文本">
            </div>
        </div>
        <button class="btn btn-default" onclick="send()">发送</button>
    </form>
</div>

<th:block th:include="include :: footer" />
</body>
<script>
    function send(){
		$.modal.loading("请求中，请稍后...");
    	var params = {}
    	if($("input[name=params]").val()!=""){
    		arr = $("input[name=params]").val().split("&");
			for (var i = 0 ; i < arr.length ; i++) {
                params[arr[i].split("=")[0]] = arr[i].split("=")[1];
			}
        }
    	if($("input[name=method]").val() == 'post'){
			$.operate.post(url,params,function (msg) {
				console.log(msg);
				$.modal.closeLoading();
			});
        }else{
			$.operate.get(url+"?"+params,function (msg) {
				console.log(msg);
				$.modal.closeLoading();
			});
        }



    }


</script>
</html>