index.html <!-- <!DOCTYPE html> --> <html lang="ja"> <head> <meta charset="utf-8"> <title>Stopwatch</title> <link rel="stylesheet" href="styles.css"> <!-- <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script> --> <script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script> </head> <body id="timers"> <div id="timer">00:00.000</div> <button id="start">Start</button> <button id="stop">Stop</button> <button id="reset">Reset</button> <select name="mintus" id ="mintus" class="mintus"> <option value="time_1" id="time1">30</option> <option value="time_2" id="time2">60</option> <option value="time_3" id="time3">90</option> </select> <button id="timeway">TimeWay</button> <div class="sum_way2"> <div id="sum_way" class="sum_way"></div> </div> <div> <button id="sum">計算</button> <div id="sum_account" ></div> <button id="php">php</button> </div> <script src="main.js"></script> <script> // ajax処理 $(function () { $('#php').click(function(){ $.ajax({ url:"more.php", type:"post", dataType:"json", data:{'timer':$("#timer").val()} }).done(function(response){ let arrye = JSON.parse(response); alert(arrye); }).fall(function(response) { alert('not'); }) }) }) </script> </script> </body> </html>
ajax処理をしようしたいですが
main.js:128 Uncaught TypeError: $.ajax(...).done(...).fall is not a function
at HTMLButtonElement.<anonymous> (main.js:128)
at HTMLButtonElement.dispatch (jquery-3.2.1.min.js:3)
at HTMLButtonElement.q.handle (jquery-3.2.1.min.js:3)
(anonymous) @ main.js:128
dispatch @ jquery-3.2.1.min.js:3
q.handle @ jquery-3.2.1.min.js:3
index.html:1 Access to XMLHttpRequest at 'file:///Users/kobayashijunki/projects/javascript/more.php' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, chrome-untrusted, https.
jquery-3.2.1.min.js:4 POST file:///Users/kobayashijunki/projects/javascript/more.php net::ERR_FAILED
のエラーが発生してしまう
上記のコメントアウとしているコードを戻したり、min.jsでなく、slim.min.jsにしてもエラーが発生してしまうので、解決方法をお教えください。
回答1件
あなたの回答
tips
プレビュー