locked
JavaScript in view calling multiple time when get partial view by ajax call and going back to view and press back button RRS feed

  • Question

  • User1589968622 posted

    In main page I'm attaching partial view and adding their back click event code that are same for main back, but when multiple time going to partial page and coming back to main back and in main back when  i click back button repeatedly back event fired their how many time i visited partial view, how I resolve this issue..

    Thursday, April 8, 2021 11:58 AM

All replies

  • User-474980206 posted

    ajax calls are not in the location history. maybe your page is submitting also when it makes ajax call. you do not explain how the ajax call is made or how your navigation works, so we can not help.

    Thursday, April 8, 2021 7:30 PM
  • User1686398519 posted

    Hi anil bhadke, 

    If it is convenient, can you provide part of the view and the code that calls the view?

    Generally speaking, putting javascript code in partial view is not a good way.

    In addition, if you want to reuse javascript, just put it in a separate js file, and then include this js file in each main view that needs this javascript.

    Best Regards,

    YihuiSun

    Friday, April 9, 2021 7:51 AM