2

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';  
                }
            }
        });
    }   
    });
user2412936
  • 349
  • 2
  • 6
  • 16
  • Possible duplicate of: http://stackoverflow.com/questions/2331749/jquery-in-codeigniter-inside-the-view-or-in-external-js-file or http://stackoverflow.com/questions/7415468/how-not-to-hard-code-codeigniter-link-in-js-file – Hashem Qolami Aug 06 '13 at 10:41

1 Answers1

-2

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';  
    }
}
Nil'z
  • 7,487
  • 1
  • 18
  • 28