开发者

Event handled attached to form submit is not invoked

开发者 https://www.devze.com 2023-03-30 05:31 出处:网络
This is an extension to the problem already posted here: display an alert message on successfull submission of a form

This is an extension to the problem already posted here: display an alert message on successfull submission of a form

Another problem has arisen now. Until now I was calling this function onclick event of a "submit" button. But now my requirements have changed a little. Now I have to call this function by clicking a link. The html code for that link is as shown below:

<a href="javascript:void(0);" onclick="javascript:customTargetReportToCSV('saveReport',0);">
    Save Report 
    <img height="16" width="16" style="vertical-align: bottom;" src="/img/icn_export.gif" alt="export">
</a>

And now nothing is 开发者_JS百科working. The event handler attached with the .submit() is not getting invoked at all.


Give an id to your anchor tag like id="custom_targeting_param_form"

and then replace submit function with click as given by ShankarSangoli in your previous post.

$("#custom_targeting_param_form").submit(function(e){

to

$("#custom_targeting_param_form").click(function(e){


@Peter , thanks much for your reply . It was really useful. Below is what I did :

$("#save_report").click(function()
                {
                    $.ajax({
                        url : actionOfForm,
                        type : $('#custom_targeting_param_form').attr("method"),
                        data : $('#custom_targeting_param_form').serialize(),
                        success : function(){
                            alert('Report Saved successfully');
                            $("#showOrExportCustomTargetingReport").val('showReport');  
                        }
                    });
                    return false;
                });

Hope this will be useful for other users facing the same problems as I did.

0

精彩评论

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