0
解碼它,我送一個URL作爲請求參數的一部分使用encodeURIComponent方法對服務器像使用encodeURIComponent方法和服務器端的
http://www.regis.edu/regisgpcd.asp?sctn=cpedcn&p1=ap&p2=EDFD&p3=cd3Dcd&_=1332612418587
這是服務器看到:
http://www.regis.edu/regisgpcd.asp?sctn=cpedcn&p1=ap&p2=EDFD&p3=cd
雖然我有先將它插入數據庫再加上encodeURIcomponent,我得到一個錯誤,它在數據庫中找不到。
這個URL格式如下,雖然我再次將它插入encodeURIcomponent之後。我猜在將它插入列之前,mysql會將其轉換爲常規類型。
http://www.regis.edu/regisgpcd.asp?sctn=cpedcn&p1=ap&p2=EDFD&p3=cd
我該如何解決這個問題?任何想法?
這是我的插入代碼:
$.ajax({
type : "GET",
url : '/tree/insertResult/?url=' + encodeURIComponent(url) + '&title=' + encodeURIComponent(title)+'&folder='+folderName+'&snippet='+encodeURIComponent(snippet),
cache : false,
success : function(res) {
if(res == "F")
notification("Operation Failed", "You have that bookmark in that folder!");
else{
folderName = res;
notification("Operation Suceeded", "Bookmark has been created.");
updateFolderContent(url, title, folderName, snippet);//it is in _filetree_javascript.html.erb
}
},
error : function(x, y, z) {
alert(x.responseText);
}
});
}
這是我的取出碼:
$.ajax({
type : "GET",
url : '/tree/deleteResult/?title='+encodeURIComponent(title)+"&url="+encodeURIComponent(url),
cache : false,
success : function(res) {
if(res == "F") //if F is returned from server it means "There is a folder with same name"
notification("Operation Failed", "Bookmark cannot be deleted! Sorry :(");
else
notification("Operation Succeed", "Bookmark've been deleted.");
deleteResult(domObj);
},
error : function(x, y, z) {
alert(x.responseText);
}
});
}
你使用jquery ajax嗎? – Engineer 2012-03-24 18:32:12
是的我使用它 – erogol 2012-03-24 18:40:45
嘗試在你的ajax設置對象中設置'cache:false'。 – Engineer 2012-03-24 18:44:23