我有這樣的:的Javascript正確的編碼
var passwordpolicies = {
shouldbecomplex: shouldbecomplex,
shouldnotbeusername: shouldnotbeusername,
shouldnotincludeusercharacters: shouldnotincudeusercharacters,
passwordminage: passwordminage,
passwordmaxage: passwordmaxage,
passwordminlength: passwordminlength,
passwordmaxlength: passwordmaxlength,
passwordchronic: passwordchronic
};
var iprange = {
enableiprange: enableiprange,
iplist: ipList
};
但我需要得到完全的:我怎樣才能做到這一點?
iprange =%7B%22enableiprange%22%3Atrue%2C%22iplist%22%3A%5B%22155.56.68.217%22%2C%22156.187.50.4%22%5D%7D & passwordpolicies =%7B% 22shouldbecomplex%22%3Atrue%2C%22shouldnotbeusername%22%3Afalse%2C%22shouldnotincludeusercharacters%22%3Afalse%2C%22passwordminage%22%3A-1%2C%22passwordmaxage%22%3A-1%2C%22passwordminlength%22%3A6% 2C%22passwordmaxlength%22%3A-1%2C%22passwordchronic%22%3A-1%7D
當然,我在對象中的變量中有正確的值。
我不是那個熟悉的編碼,並試圖 encodeURIComponent方法和jQuery.param,但沒有成功。
在做:encodeURIComponent({iprange, passwordpolicies})
我得到這個:
%5Bobject%20Object%5D
時並執行:jQuery.param({iprange, passwordpolicies})
我得到這個:
iprange%5Benableiprange %5D = false & iprange%5Biplist%5D%5B%5D = 155.56.68.217 & ipra NGE%5Biplist%5D%5B%5D = 156.187.50.4 & passwordpolicies%5Bshouldbecomplex%5D =真& passwordpolicies%5Bshouldnotbeusername%5D =假& passwordpolicies%5Bshouldnotincludeusercharacters%5D =假& passwordpolicies%5Bpasswordminage%5D = & passwordpolicies%5Bpasswordmaxage%5D = & passwordpolicies%5Bpasswordminlength%5D = 6個& passwordpolicies%5Bpasswordmaxlength%5D = & passwordpolicies%5Bpasswordchronic%5D =
做這件事時: encodeURIComponent方法(JSON.stringify(MyObj中)) 我得到這樣的:
%7B%22Prange%22%3A%7B%22enableiprange%22%3Afalse%2C%22iplist%22%3A%5B%22155.56.68.217%22%2C%22156.187.50.4%22%5D%7D% 2C%22passwordpolicies%22%3A%7B%22shouldbecomplex%22%3Atrue%2C%22shouldnotbeusername%22%3Afalse%2C%22shouldnotincludeusercharacters%22%3Afalse%2C%22passwordminage%22%3A%22%22%2C%22passwordmaxage%22% 3A%22%22%2C%22密碼長度%22%3A%226%22%2C%22密碼長度%22%3A%22%22%2C%22密碼時間%22%3A%22%22%7D%7D
您需要向我們展示你嘗試之前,我們可以告訴你什麼是錯的 – Quentin
'JSON.stringify()'+'encodeURIComponent方法()' – Andreas
@Quentin:請看看我的編輯。 – progNewbie