0

I have view with search bar and displaying table based on that search. So starting view looks like this: enter image description here

I am displaying partial view in <div id="ajaxPartialView"></div>

So when i enter some text and click search, i m displaying partial view table with ajax call, and recive results like this:

enter image description here

That works ok, but when i go to some other page and press back in browser, my text input is saved, but div with partial view is empty like this:

enter image description here

Why input is saved on page back and div with partial view is empty. I dont call ajax call on page load or anything, i just call it on search button click. Is there any solution or explanation why that ajax div is empty on page back ?

Notch
  • 47
  • 1
  • 7

1 Answers1

0

It is because when page loads,the button is not clicked,so the partial view will not show.What about change your code to when the search input is changed,the ajax will be called.So that the partial view will not be empty when you press back in browser.

$("#search").change(function () {
            callAjax()
        })
function callAjax()
{
    ...
}
Yiyi You
  • 16,875
  • 1
  • 10
  • 22