Monday, December 11, 2017

jquery ajax cache false ( MVC / c# / jquery / ajax )


Not reaching debug point on jquery ajax call



It may happen that we are using jquery ajax call and the program does not reach debug point in your controller action. This happens when ajax cache is enabled. Disabling of the cache during your ajax call can solve this problem. Below you can see an example.


$.ajax({
                url: _your_url,              
                cache: false,
                success: function (result) {
                    // _success_
                },
                error: function (req, err) {
                   // _error_
                }
            });

Enable the cache only when your ajax call returns the same result even on multiple requests. But if you need to get fresh data from controller action each time on your ajax call, better disable the cache.

No comments:

Post a Comment