ajax在chrome或ie中不起作用,但在firefox中起作用

lsmd5eda  于 2021-09-13  发布在  Java
关注(0)|答案(1)|浏览(353)

我的一个网站出现了一些意想不到的问题,我原以为我的ajax可以正常工作,但后来我注意到它只在firefox中工作。
在chrome控制台中调试时,我看到:

invoke.js:1 Console was cleared
main.js:42 in Startnull
prompt.js:1 Uncaught SyntaxError: Identifier 'originalPrompt' has already been declared
/favicon.ico:1 Failed to load resource: the server responded with a status of 404 (Not Found)
Unchecked runtime.lastError: The message port closed before a response was received.
Unchecked runtime.lastError: The message port closed before a response was received.
Unchecked runtime.lastError: The message port closed before a response was received.
Unchecked runtime.lastError: The message port closed before a response was received.
Unchecked runtime.lastError: The message port closed before a response was received.
Unchecked runtime.lastError: The message port closed before a response was received.
main.js:42 in Startnull
prompt.js:1 Uncaught SyntaxError: Identifier 'originalPrompt' has already been declared
mc_ns_26.06.2018_728x90_8_en.jpg:1 Failed to load resource: net::ERR_BLOCKED_BY_CLIENT
main.js:42 in Startnull
prompt.js:1 Uncaught SyntaxError: Identifier 'originalPrompt' has already been declared
1588423983.jpg:1 Failed to load resource: net::ERR_BLOCKED_BY_CLIENT
DevTools failed to load source map: Could not load content for chrome-extension://ljdobmomdgdljniojadhoplhkpialdid/common/browser-polyfill.js.map: HTTP error: status code 404, net::ERR_UNKNOWN_URL_SCHEME
DevTools failed to load source map: Could not load content for chrome-extension://mooikfkahbdckldjjndioackbalphokd/assets/atoms.js.map: HTTP error: status code 404, net::ERR_UNKNOWN_URL_SCHEME
DevTools failed to load source map: Could not load content for chrome-extension://mooikfkahbdckldjjndioackbalphokd/assets/polyfills.js.map: HTTP error: status code 404, net::ERR_UNKNOWN_URL_SCHEME
DevTools failed to load source map: Could not load content for chrome-extension://mooikfkahbdckldjjndioackbalphokd/assets/escape.js.map: HTTP error: status code 404, net::ERR_UNKNOWN_URL_SCHEME
DevTools failed to load source map: Could not load content for chrome-extension://mooikfkahbdckldjjndioackbalphokd/assets/playback.js.map: HTTP error: status code 404, net::ERR_UNKNOWN_URL_SCHEME
DevTools failed to load source map: Could not load content for chrome-extension://mooikfkahbdckldjjndioackbalphokd/assets/record.js.map: HTTP error: status code 404, net::ERR_UNKNOWN_URL_SCHEME
jquery-3.5.1.js:10099 POST https://www.quiz-griz.com/30-how-well-do-you-know-the-vampire-diaries-characters/ajax-answer.php 404 (Not Found)
send @ jquery-3.5.1.js:10099
ajax @ jquery-3.5.1.js:9682
AjaxRequest @ global.js:11
AnswerQuestion @ global.js:67
onclick @ (index):86

问题在于:

jquery-3.5.1.js:10099 POST https://www.quiz-griz.com/30-how-well-do-you-know-the-vampire-diaries-characters/ajax-answer.php 404 (Not Found)

它试图在重写.htaccess url后加载我的ajax文件,位置就在这里 /ajax/ajax-answer.php 在我的服务器和javascript代码中。
这是引用文件位置的我的代码:

function AnswerQuestion(el) {
  const $el = $(el);
  //alert($el.data('question-id'));
  if ($el.hasClass('disabled'))
    return;
  $el.addClass('disabled');
  const url = '/ajax/ajax-answer.php';
  let pars = {
    answer: $('input[name=questions]:checked', '#question-form').val(),
    takenQuizId: $el.data('taken-quiz-id'),
    quizId: $el.data('quiz-id'),
    questionId: $el.data('question-id'),
  };
  AjaxRequest(url, pars, function(response) {
    // success goes here
    $el.removeClass('disabled');
    console.info("SUCCESS->", response);
    location.reload();
  },
  function (response) {
    // fail goes here
    $el.removeClass('disabled');
    console.info("FAIL->", response);
  });
}

$(document).ready(function() {
  $("#question-form input").on("change", function(){
    $(".btn").removeClass('disabled');
  });
});

这在firefox中运行良好,但在chrome和InternetExplorer中它不想工作。
我想不出要尝试什么,有什么我可以调整来解决这个问题吗?

gupuwyp2

gupuwyp21#

信不信由你,这在两种浏览器上都是缓存问题!一旦清除,它开始工作。

相关问题