简体   繁体   中英

how to redirect to next page using external js in codeigniter

before i have used the following code in same file to redirect to next page. but am using seperate js file. when clicking on button it is showing disallowed characters. how to give the url. can anyone suggest me. thanks.

$.validator.setDefaults({
    submitHandler: function() {
        var form_data = {
            state: $("#state").val(),
            fiscal_yr: $("#fiscal_yr").val(),
            high: $("input:radio[name=high]:checked").val(),
            date_biennial_budget: $("#date_biennial_budget").val(),
        //  password: $("#password").val(),
            is_ajax: 1

        };
        $.ajax({
            cache : false,
            type: "POST",
            url: '<?php echo base_url();?>survey/actual_budget',
            data: form_data,
            success: function(response)
            {
                if (response != 'failed') {
                    window.location.href = '<?php echo base_url();?>survey/actual_budget';  
                }
            }
        });
    }   
    });

In your template header define:

<script type="text/javascript">
    var baseUrl = '<?=base_url()?>';
</script>
<script type="text/javascript" src="external.js"></script>

In your external.js file:

success: function(response)
{
    if (response != 'failed') {
        window.location.href = baseUrl+'survey/actual_budget';  
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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