English 中文(简体)
在重新定位之前撰写数据库
原标题:Write into database before redirecting

有一个吨,被点击(html)后被转往另一页。 在“javascript”中,这一功能把一些新价值写进数据库表,然后点击这个纽子。 我的问题是:在将数据输入数据库之前,重新定位,因此,新网页上仍然有旧的价值观。 是否很容易改变这些步骤(将注意力转移到数据库中)? 感谢您的建议

问题回答

只是把转头转向亚克斯呼吁的警示,你说,

<a href="#" id="savedata">Save data</a>
<script type="text/javascript">
    $(document).ready(function() {
        $("#savedata").click(function() {
            $.post( /savemydata/ , { mydata:  data  }, function(data) {
                window.location.href =  /newpage/ 
            });
            return false;
        });
    });
</script>

如果纽特州实际上提交表格,那么你可能希望掩盖纽特,然后简单地通过增加:

$("#buttonID").trigger( click );

利用Ajax书写数据,然后在Ajax向中方向扔 throw。 这将确保在向数据库提交信息之前,不会发生这一方向。 这将有助于看到你的一些法典能够作出更好的回答。 此外,如果你是新到阿加西,则最有可能与大 j合。

将该代码改用新网页,以备你提出节日请求。

与此类似:

$.post( /savemydata/ , { my:  data  }, function(data) {
    //the Ajax post has been completed successfully, so now we redirect
    window.location.href =  /newpage/ 
});

这取决于你如何编写数据库。 但是,在装上新页时将数据传送到服务器的通常和建议方式是使用URL参数。 如果你使用类似东西的话

<f或m action="/next.php" method="POST">
 <input type="hidden" name="data" value="values" />
 <button type="submit" value="Next Page" />
</f或m>

<a href="/next.php?data=values">Next Page</a>
// also simply usable with
window.location = "/next.php?data=values";

你可以肯定,

  1. the data reaches the server,
  2. can be processed (written to the database) bef或e
  3. the requested page is returned.

You could also make use of cookies. Just write your data values into document.cookie, and they will be transp或ted to the server with the same request that asks f或 the new page.





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签