is it there any way to post a form to more URLs?
I need it in javascript..
For example: I've got 2 documents: 1.php and 2.php.. I want the form to post data to the both of these files, but go to the 1.php..
Do you know any way?
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a limit to how many levels you can nest i
- Laravel Option Select - Default Issue
- How to toggle on Order in ReactJS
- PHP Recursively File Folder Scan Sorted by Modific
All above solution should work, but remember ajax is only alowed in same domain posting. This mean you are on http://example.com, you can only post to example.com/etc or sub.example.com
If you really want to cross domain posting, you should create an empty ifram as target (id="iframeid") then change the target of the form to it:
After that you can use javascript to post to one page, and then change action url and repost again
the quick and dirty way to do this is to post the form to one script which will in turn post it to a second script.
You need a form with the action "1.php" and jQuery.
Using JavaScript, yes
You'll want to make one call using the XMLHttpRequest function available in JavaScript to make an AJAX call to the php.2 script. The second call can then be done using
document.forms["FORMNAME"].submit()
.Libraries like jQuery's Ajax functions make it easier to use the XMLHttpRequest function. See the jquery.get(), jquery.post(), and jquery.ajax() (a.k.a $.get(), $.post() and $.ajax()) function documentation
Here are a few guides to doing AJAX calls using jQuery's $.post() and $.ajax() functions.
Also here is an example framework of how this can be coded up: