Loading JSON-encoded AJAX content into jQuery UI tabs

后端 未结 3 875
夕颜
夕颜 2021-02-15 12:15

We want all of our AJAX calls in our web app to receive JSON-encoded content. In most places this is already done (e.g. in modals) and works fine.

However, when using j

3条回答
  •  北荒
    北荒 (楼主)
    2021-02-15 12:43

    I had to add:

    this.dataTypes=['html']
    

    to get this to work.

    In context:

          ,ajaxOptions: {
        dataFilter: function(result,type){
          var data = $.parseJSON(result);
           // Trick jquery to think that it's html
           this.dataTypes=['html']
           return '

    '+data.credential.id+'

    '; } ,error: function( xhr, status, index, anchor ) { $( anchor.hash ).html( i18n.AJAXError + ' (' + status + ')' ); } }

提交回复
热议问题