开发者

jQuery with json

开发者 https://www.devze.com 2022-12-16 07:37 出处:网络
I have an MVC app that does a lot of work with jQuery ajax (post), to retreive customer info and load it to the web page.

I have an MVC app that does a lot of work with jQuery ajax (post), to retreive customer info and load it to the web page. The problem is, that on internet explorer 7, when I click twice a link that retrieves the info via ajax ($.post or $.getJSON), the info doesn't refresh; it shows me the info of the first customer I clicked, not the second one, so the info is wrong. I tried to make a debug on the code, and on the second click it doesn't even enter to the action that retrieves the data from the database.

I suspect that the problem is with the browser 开发者_开发问答cache, but I don't know how to handle it.

I attach my code, its working fine, expect for the problem I mention previously:

$.getJSON(pathSite + 'PorServiceQuery/GetJsonInfo', {},
                function(resp) {
                    $('#txtPhone').attr('value', resp.ClpCustomerPhone);
                    $('#txtCelPhone').attr('value', resp.ClpCelPhone);
                    $('#txtEmail').attr('value', resp.ClpEmail);
                });


I've seen this behavior if the user clicks twice before the initial response returns. Are you sure that's not what's happening (regardless of the browser)? You might want to try using Fiddler to confirm when the request is going out vs when it is returning vs when the user is clicking.

Another idea is that you can set IE cache settings to ALWAYS check for new versions of pages.


The solution was to use $.post instead of $.getJson, the reason is that the getjson does an http get and that's why I didn't saw my data refreshed.

0

精彩评论

暂无评论...
验证码 换一张
取 消