From edb30d858689c49436723584914c33e199d8894e Mon Sep 17 00:00:00 2001 From: Zeno Zeng Date: Sat, 19 Dec 2015 18:22:34 +0800 Subject: [PATCH] make ajaxRequest simpler --- template/utils/send_sample_request.js | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/template/utils/send_sample_request.js b/template/utils/send_sample_request.js index 5e80632f..da34b17c 100755 --- a/template/utils/send_sample_request.js +++ b/template/utils/send_sample_request.js @@ -77,38 +77,15 @@ define([ // send AJAX request, catch success or error callback var ajaxRequest = { url : url, - dataType : "json", - contentType: "application/json", headers : header, + data : param, type : type.toUpperCase(), success : displaySuccess, error : displayError }; - if (type === 'get') { - ajaxRequest.url = url + paramToQueryParms(param), - ajaxRequest.dataType = "text"; - ajaxRequest.contentType = "text/plain"; - } else { - if ( ! $.isEmptyObject(param)) { - ajaxRequest.data = JSON.stringify(param); - } - } $.ajax(ajaxRequest); - function paramToQueryParms(param) { - var p = 0; - var queryParms = ""; - for (var k in param) { - if (p === 0) { - queryParms += "?" + k + "=" + param[k]; - } else { - queryParms += "&" + k + "=" + param[k]; - } - p++; - } - return queryParms; - } function displaySuccess(data) { var jsonResponse;