###前提・実現したいこと
クロスドメイン(jquery.xdomainajax.js)を使用した機能が突然動かなくなりました。
###発生している問題・エラーメッセージ
クロスドメイン(jquery.xdomainajax.js)を使用した機能でエラーになってしまいました。 今まで、正常に外部サイトから情報を取得していたのですが、突然動かなくなってしまいました。 エラー内容は以下の通りです。 XMLHttpRequest : 200 textStatus : parsererror errorThrown : jQuery3110247705122841547_1505822564193 was not called 使用しているjsは jquery-3.1.1.min.jsとjquery.xdomainajax.jsです。 Yahoo!のYQLというサービス終了に伴うエラーは解決しており、その後ずっと機能していました。 スマホのsafariではエラーにならず、機能していますが、パソコンのchromeとIE、firefoxでは機能しません。 よろしくお願いします。
###該当のソースコード
$(function kawase1() { $.ajax({ url: "http://keisanki.me/widget/type01/TRY/100", type: 'GET', success: function(data) { var nm = $(data.responseText).text().replace(/>/g, '>').replace(/</g, '<'); var dpObj = new DOMParser(); var xmlDoc = dpObj.parseFromString(nm, "text/xml"); $('#container1').html("= "); $('#container2').html($(xmlDoc).find('.result')); $('#container3').html(""); }, error: function(XMLHttpRequest, textStatus, errorThrown) { $("#container1").html("XMLHttpRequest : " + XMLHttpRequest.status); $("#container2").html(" textStatus : " + textStatus); $("#container3").html(" errorThrown : " + errorThrown.message); } }); }); jquery.xdomainajax.jsの中身はYahoo!のYQLというサービス終了対応しており以下です。 jquery-3.1.1.min.jsは改変してません。 jQuery.ajax = (function(_ajax){ var protocol = location.protocol, hostname = location.hostname, exRegex = RegExp(protocol + '//' + hostname), YQL = 'http' + (/^https/.test(protocol)?'s':'') + '://query.yahooapis.com/v1/public/yql?callback=?', query = 'select * from htmlstring where url="{URL}" and xpath="*"'; function isExternal(url) { return !exRegex.test(url) && /:///.test(url); } return function(o) { var url = o.url; if ( /get/i.test(o.type) && !/json/i.test(o.dataType) && isExternal(url) ) { // Manipulate options so that JSONP-x request is made to YQL o.url = YQL; o.dataType = 'json'; o.data = { q: query.replace( '{URL}', url + (o.data ? (/?/.test(url) ? '&' : '?') + jQuery.param(o.data) : '') ), diagnostics: true, env: 'store://datatables.org/alltableswithkeys', format: 'xml' }; // Since it's a JSONP request // complete === success if (!o.success && o.complete) { o.success = o.complete; delete o.complete; } o.success = (function(_success){ return function(data) { if (_success) { // Fake XHR callback. _success.call(this, { responseText: (data.results[0] || '') // YQL screws with <script>s // Get rid of them .replace(/<script[^>]+?/>|<script(.|\s)*?/script>/gi, '') }, 'success'); } }; })(o.success); } return _ajax.apply(this, arguments); }; })(jQuery.ajax);
###試したこと
ajaxの設定でtype: 'GET',の下にdataType 'html',やdataType 'text',、dataType 'json',と色々追加記述を変更してみましたが、ダメでした。
###補足情報(言語/FW/ツール等のバージョンなど)
jquery
回答3件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2017/10/02 02:06
2017/10/02 02:27
退会済みユーザー
2017/10/02 14:26