htmlを開いても何も表示されません。
なぜでしょうか?
phpを直接開くと表示されます。
html
<html lang="ja"> <body> <script> function event() { $.ajax({ type: 'POST', url :'test.php', data:{ key:value } }).fail(function(){ alert('error'); }).done(function(){ alert('success'); }); } setInterval(event, 10); </script> </body> </html>
php
<!DOCTYPE html> <html lang="ja"> <body> test </body> </html>
やっぱりダメです。
HTML
<html lang="ja"> <body> <script> function event() { $.ajax({ type: 'POST', url :'test.php', data:{ key:value } }).fail(function(){ alert('error'); }).done(function(){ alert('success'); }); } setInterval(event, 10); </script> <script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.min.js"></script> </body> </html>
htmlを開いても
開くとはブラウザにhtmlのURLを打ち込むことです。
phpを直接開くとはphpのURLをブラウザに直接打ち込むことです。
エラーもサクセスも
何も表示されません。
URLはhttpsです。
ブラクラについて
setIntervalを使うと負荷が高くなるけどsetTimeoutを使えば10msごとでも負荷高くならないよね?
出来ました!!
出来ました!!!
HTML
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div id="edit_area"></div> <script> var fn = function() { $.ajax({ type: 'post', url: "test6.php", success: function(result){ document.getElementById('edit_area').innerHTML = result; } }); setTimeout(fn,10); }; fn(); </script>
PHP
<?php $result = file_get_contents ("10.txt"); file_put_contents("10.txt", $result + 1); echo $result; exit; ?>
まだ回答がついていません
会員登録して回答してみよう