开发者

How to catch the post data of the submitted form

开发者 https://www.devze.com 2023-02-16 18:04 出处:网络
So that I开发者_高级运维 can send those data using perl/php or any other programmatically. Say I\'ve a website with a combo box containing 100 cities submitting each city would get me the list of ser

So that I开发者_高级运维 can send those data using perl/php or any other programmatically.

Say I've a website with a combo box containing 100 cities submitting each city would get me the list of service centers in the city.

So I want to use a perl code where I'd loop all the cities and capture all the results, format them suitably in html for use in my website.

Doing all these using jquery etc will be manual. Also using jquery I'll not be able to catch response in easy way and save it on the hard disk as html file.


im not sure who is sending it where from your description. But i guess that you have an HTML form which sends those data to some PHP script . you specify the PHP in and you catch them on server side using $_POST["variable"] if you want to send them somewhere else from your php script, use curl http://cz.php.net/manual/en/book.curl.php


This did the trick, I had to learn jquery finally:

var chk = [];   
$("#splocator2 #stateid option").each(function() {
    chk.push($(this).val());
});
alert(chk.length);
for (i = 0; i < chk.length; ++i){
    $("#splocator2").attr("target", "_blank");
    $("#stateid option:eq(0)").attr("selected", "selected");
    $("#stateid option:eq(0)").attr("value", chk[i]);
    $("#splocator2").submit();
}


JavaScript running on a page can not access variables POST'd to it AFAIK.

You may be thinking of sending an XHR to your server side code.


You may use the serialize() method:

$(function() {
    $("#myForm").submit(function() {
        alert($(this).serialize());
        // No thanks I'm gonna use my own post request
        // code here!
        return false;
    });
});

Example.

0

精彩评论

暂无评论...
验证码 换一张
取 消