0
$("#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>

每当我单击这些按钮中的任何一个时,URL 都会变成localhost:3338/news.html?

我没有得到任何参数。我不知道为什么。你们能给我解决方案吗?在此先感谢。

4

2 回答 2

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()
于 2013-08-08T12:31:43.463 回答
0
window.location = "'"+'news.html?type=' + type +     '&subtype=' + subtype+'&id='+id+"'";

有很多人''尝试这个:

window.location = 'news.html?type=' + type +     '&subtype=' + subtype+'&id='+id;

然后,如果您的网址中有空格,您应该对其进行解码

是否无法更改后退导航的参数。后退导航总是指向最后一页:

URL: news.html?type=1 
-> (navigate to) URL: news.html?type=2 
<- (history.back() called) URL: news.html?type=1 
于 2013-08-05T07:20:36.657 回答