jquery (ajax) redirect to another domain

后端 未结 3 836
陌清茗
陌清茗 2021-01-17 06:18

I have the jquery json request in the following format:

JSON request:

$.getJSON(\'http://xyz.com\',function(result) {});

If the req

3条回答
  •  隐瞒了意图╮
    2021-01-17 06:40

    Did you try this?

    function addImage(item) {
     $("").attr("src", item.media.m).appendTo("#images");
    }
    
        var jqxhr = $.getJSON("http://xyz.com",function(data) {
        $.each(data.items, function(i,item){  //sample
           addImage(item);
        })
        .error(function() { 
                  var jqxhrFailover = $.getJSON("http://zzz.com", function(data) {
        $.each(data.items, function(i,item){  //sample
           addImage(item);
        }).error(function(){ alert('both failed!'); });
    

提交回复
热议问题