weixin_33749242 2016-11-11 12:53 采纳率: 0%
浏览 31

获取表单网址而不提交

I am a newbie when it comes to JQuery or Javascript -- so apologies if this is an easy one...

Basically, I have a GET form -- which I need to intercept -- meaning I need to call javascript instead of actually submitting the form, when the submit button is pressed. I would like to have the complete URL as a output... something like...

http://server/cgi-bin/status.py?val=1223&val2=434334&val3=4343 

form -

Basically, I need the form to process the URL as if it would submit, but not submit. Main requirement is to send this link vial mail to the customers so they can track the job progress using this link

Thanks, Prince

  • 写回答

2条回答 默认 最新

  • Memor.の 2016-11-11 12:59
    关注

    This can be done with something like this

     $('form').on('submit', function(event) {
        var url = '<insert-path-to-desired-script>?' + $(this).serialize();
    
        event.preventDefault();
    });
    

    The event.preventDefault() makes sure the form doesn't actually submit.

    url then contains a full url with all the form properties in it.

    评论

报告相同问题?