$("#saveNews").click(function() {
alert("clicked on save");
alert(idx);
alert(id);
alert(type);
alert(subtype);
window.location = "'"+'news.html?type=' + type + '&subtype=' + subtype+'&id='+id+"'";
toSaveNews(idx);
});
function toSaveNews(index) {
alert("inside saving");
alert(index);
var newsFD = new FormData($("#fileinfonews"));
var news = $("#newsDetails").val();
alert(customer);
alert("stop");
newsFD.append("reqData1", reqData1);
newsFD.append("reqData2", reqData2);
if (news == "") {
bootbox.alert("News can't be empty.Enter something."); else {
alert('b4 ajax');
$.ajax({
type : "POST",
url : "/path1/saveNews",
data : newsFD,
processData : false,
contentType : false,
success : function(data) {
alert("success!!!!!!!!");
}
在这里,我甚至在Ajax之前就收到了警报。上传,后退和重置有3个按钮。 'savenews'是上传按钮的ID。我在后面的按钮中输入:
<button class="btn" id="back" onclick="history.back();">Back</button>
每当我点击这些按钮中的任何一个时,网址就会变为 localhost:3338 / news.html?
我没有得到任何参数。我不知道为什么。你们可以给我解决方案吗?先谢谢。
答案 0 :(得分:0)
window.location = "'"+'news.html?type=' + type + '&subtype=' + subtype+'&id='+id+"'";
有很多''
试试这个:
window.location = 'news.html?type=' + type + '&subtype=' + subtype+'&id='+id;
如果您的网址中有空格,则应decode。
是否无法更改后退导航的参数。后退导航始终指向最后一页:
URL: news.html?type=1
-> (navigate to) URL: news.html?type=2
<- (history.back() called) URL: news.html?type=1
答案 1 :(得分:0)
$("#saveNews").click(function(event) {
event.preventDefault();
toSaveNews(idx);
});
//Basically,what the problem is,the form is being submitted automatically.So,prevent that using preventDefault()