开发者

json request not working in IE and issue with cache

The following code works only in Firefox, but not in IE. The word "Meanscoil na mBrait开发者_开发知识库hre Criostaí" brakes the JSON file:

"2028425":[19, "Awaiting Correction", "", "Meanscoil na mBraithre Criostaí"],



$(document).ready(function() {
  $('#ticketsearch').click(function() {
    var ticketcode = $('[name=ticketcode]').val();
    $.getJSON('/import/envelope.json', function(data) {
      $('.ticket').text(data[ticketcode][3]);
      $('.envstatus').text(data[ticketcode][1]);
      $('.track').text(data[ticketcode][2]);
      $('.track').attr("href", data[ticketcode][2]);
    });
  });
});

PS> How can I clear cache after each JSON request.


Caching issues...

Note that IE is the only browser platform that utilizes caching in AJAX requests because they treat an AJAX request no different then a normal browser request.

$(document).ready(function() {
    $('#ticketsearch').click(function() {
        var ticketcode = $('[name=ticketcode]').val();
        $.getJSON('/import/envelope.json', function(data) {
            $('.ticket').text(data[ticketcode][3]);
            $('.envstatus').text(data[ticketcode][1]);
            $('.track').text(data[ticketcode][2]);
            $('.track').attr("href", data[ticketcode][2]);
            $.ajaxSetup({ cache: false });       // <------this will disable caching
        });
    });
});


You have to add following code in your jsp page head section

<script src="https://github.com/douglascrockford/JSON-js/blob/master/json2.js" />

Try this one and check.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜