dongqiu3254 2018-10-17 17:14
浏览 64

在javascript或CI中按下浏览器后退,前进或刷新按钮时,如何将页面重定向到特定URL

I have created a page using Codeignitor , Ajax and javascript which is just like dynamic dropdown selection. This is my localhost URL.

http://localhost/nwfnb/sbi-bank/ifsc-code/andaman-and-nicobar/andaman/aberdeen-bzr-evening-city.

What i want here is when a user press backword or forward or refresh button then I want URL like this.

http://localhost/nwfnb/sbi-bank/ifsc-code.

This is just a single view page code using Ajax and CI. I am just mentioning the second selection option code.

View:

 $('#state').on('change',function(){
                    var stateID = $(this).val();
                    var countryName=  $('#country option:selected').text().toLowerCase();
                    var stateName=  $('#state option:selected').text().toLowerCase();
                    if(stateID){
                        $.ajax({
                            type:'POST',
                            url:'<?php echo base_url('bank/getBranch'); ?>',
                            data:'state_id='+stateID,
                            success:function(data){
                                $('#city').html('<option value="">Select City</option>'); 
                                var dataObj = jQuery.parseJSON(data);
                              //  alert (dataObj);
                                if(dataObj){
                                    $(dataObj).each(function(){
                                        var option = $('<option />');
                                       // alert(option);
                                        option.attr('value', this.id).text(this.branch_name);           
                                        $('#city').append(option);
                                        window.history.replaceState("", "", "<?php echo base_url(); ?>sbi-bank/ifsc-code/"+countryName+"/"+stateName);
                                      //  window.location = "//www.aspsnippets.com/"; 
                                    });
                                }else{
                                    $('#city').html('<option value="">Branch not available</option>');
                                }
                            }
                        }); 
                    }else{
                        $('#city').html('<option value="">Select district first</option>'); 
                    }
                });

Is there any way to get only the above mentioned url using CI or javascript

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何用python向钉钉机器人发送可以放大的图片?
    • ¥15 vue3加ant-design-vue无法渲染出页面
    • ¥15 matlab(相关搜索:紧聚焦)
    • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
    • ¥15 路易威登官网 里边的参数逆向
    • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
    • ¥50 需求一个up主付费课程
    • ¥20 模型在y分布之外的数据上预测能力不好如何解决
    • ¥15 processing提取音乐节奏
    • ¥15 gg加速器加速游戏时,提示不是x86架构