如何在没有刷新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

Add this in your input or anchor element:

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