简体   繁体   English

解析数据,然后将其发送到操作链接或人工POST请求

[英]Parse data before sending it to action link or artificial POST request

I have a form and it have action="http://anotherhost.com" . 我有一个表单,它有action="http://anotherhost.com" But I have a problem, before sending it to another host I need to save entered data to database and here is a problem, how to do it? 但是我有一个问题,在将它发送到另一个主机之前,我需要将输入的数据保存到数据库中,这是一个问题,该怎么办?

I have idea, but don't know how to realise it. 我有主意,但不知道如何实现。
1) Change action="http://anotherhost.com" to my site, parse entered data and add into database, but then after this I need to simulate artificial POST request to another host. 1)将action="http://anotherhost.com"更改为我的站点,解析输入的数据并添加到数据库中,但是在此之后,我需要模拟对其他主机的人工POST请求。
2) First parse it with JS (AJAX) and after parsing it, let to send form to another host. 2)首先使用JS(AJAX)解析它,然后解析它,然后将表单发送到另一台主机。

Your second option is probably the best way to go, something like this should work! 第二种选择可能是最好的方法,类似的东西应该可以工作!

http://jsfiddle.net/7Sq3J/ http://jsfiddle.net/7Sq3J/

$('form').submit(function(event) {
    $.post('http://example.net/', $('form').serialize(), function(data){
        // handle returned data in here
    });
});

This will use a POST request, and send everything you send in the form to http://example.net/ 这将使用POST请求,并将您以表格形式发送的所有内容发送到http://example.net/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM