开发者

json request not working in IE and issue with cache

开发者 https://www.devze.com 2023-02-15 03:00 出处:网络
The following code works only in Firefox, but not in IE. The word \"Meanscoil na mBrait开发者_开发知识库hre Criostaí\" brakes the JSON file:

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

精彩评论

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