OK現在我張貼的數據是這樣的:
function post_to_url(path, params, method) {
console.log ("Inside post_to_url>>>>>>>>");
method = method || "post"; // Set method to post by default, if not specified.
// The rest of this code assumes you are not using a library.
// It can be made less wordy if you use one.
var form = document.createElement("form");
form.setAttribute("method", method);
form.setAttribute("action", path);
for(var key in params) {
if(params.hasOwnProperty(key)) {
var hiddenField = document.createElement("input");
hiddenField.setAttribute("type", "hidden");
hiddenField.setAttribute("name", key);
hiddenField.setAttribute("value", params[key]);
form.appendChild(hiddenField);
}
}
document.body.appendChild(form);
form.submit();
}
,並調用此方法爲:
function handleLogin()
{
var form = $("#loginForm");
var u = $("#username", form).val();
var p = $("#password", form).val();
var d = $("#dob", form).val();
if(u != '' && p!= '')
{
var finalStr = u+encodeURIComponent("|^")+p+encodeURIComponent("|^")+encodeURIComponent("|^")+"X"+encodeURIComponent("|^")+d+encodeURIComponent("|^")+"1.0"+encodeURIComponent("|^|$");
var encodedURL = encodeURI(intranetUrl+"customer/Ri_logon.asp?requestString=");
var parameters = decodeURIComponent(finalStr);
console.log("before calling post_to_url method");
post_to_url(encodedURL,parameters,'post');
}
else
{
alert("You must enter a username and password", function() {});
$("#submitButton").removeAttr("disabled");
}
}
但現在我正在從服務器輸出:「不是一個對象」。它來自服務器,當參數paased或特殊字符不完美編碼。但是我的編碼參數很好,就像我上面的原始問題。那爲什麼這樣呢?
來源
2012-07-08 09:09:53
PPD
ajax有什麼問題? – Onheiron 2012-07-08 08:16:42
_'send data without ajax ...'_ like a form submit for post,or url redirect for a get? – nbrooks 2012-07-08 08:17:19
@ OnheironHi我想在手機上開發這個應用程序。它必須支持黑莓和bada。但是在黑莓版本5中,它不支持ajax。在版本6中它工作正常 – PPD 2012-07-08 08:18:06