简体   繁体   中英

How to go back on a button click without refreshing page in jquery AJAX?

How to go back without page refreshing.Firstly, I am getting data from AJAX dynamically.but when I click Back button it takes me to the main location where it actually started.

So here's the scenario:

3 Locations

There is a button named Deposit in deposit.php when I press it.It took me to location where there are more buttons,like pay with credit card, pay with debit card etc and when I click on pay with credit card, it takes me to the location pay.php..So far everything's fine...

Here's the problem occurs

whenever I press back, it takes me back to deposit.php instead of pay.php

deposit.php

 <input type="submit" class='btn btn-primary btn-large' name="send" id="send" value="Deposit" /><br/>

pay.php

 <a id='credit'>Pay with credit card</a>
 <a id='debit' href='#'>Pay with credit card</a>

Here one thing to notice:

There are 2 anchor tag.one is without href attribute and one is with href='#'attribute

Talking about without href attribute, when I press the back button it takes me to the deposit.php(completey back, where it all started)

Talking about with href attribute, when I press the pay with credit card button.url changes to /pay.php#.When I first press the back button, it doesn't go back..if I press it twice, it goes to completely back(deposit.php)...

paying.php should I put back button in here.but can't figure out the scenario of back button

So My question is:

what should I do that whenever I press back button in chrome, it should take me back to pay.php instead of deposit.php

ps: I am using ajax jquery and page is not refreshing anywhere.it

将此添加到您的输入或锚元素中:

<button value="Back" type="Button" onclick="history.go(-1);">Go back</button>

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