简体   繁体   English

javascript在localhost上工作正常,但在实时服务器上却不能

[英]javascript working fine in localhost but not on live server

i have a comment system in php,ajax and javascript this code used to work fine in localhost but when i transfered my website to live server it does not work idk why this is my script 我在php,ajax和javascript中有一个注释系统,该代码曾经在localhost中可以正常使用,但是当我将网站转移到实时服务器时,它不起作用idk为什么这是我的脚本

 <script type="text/javascript">
$(document).on('click','.submit',function(e){
     e.preventDefault();
     $post = $(this);
    var username2 = $(this).parent().find("#username").val();
    var comment2 = $(this).parent().find("#comment").val();

    $commentsec = $(this).closest("form").next(".comments");

    //Get values of input fields from DOM structure 
    var dataString = {
        id: $(this).parent().find("#id").val(),
        username: $(this).parent().find("#username").val(),
        uid: $(this).parent().find("#uid").val(),
        comment: $(this).parent().find("#comment").val()
    };
   //Get values of input fields from DOM structure 



    $.ajax({
   url:'comments.php',  
   data:dataString,
   success:function(){
$commentsec.append('<p class="written"><a href="users.php?id= <?php echo $id3; ?>"><b style=color:black !important>'+username2+'</b> </a>'+comment2+"</p>"+'<div class="dropdown"><img src="images/ellipsis.png" class="dots"><div class="dropdown-content"><br><p  class="delete" data-delete=<?php echo $commentid; ?>">delete</p></div></div>');
     $(" #comment").val("");     
   }
   });
});

is there any way i can get error in my error log?? 有什么办法可以在错误日志中得到错误?

this is my network tab network tab 这是我的网络标签网络标签

console tab 控制台标签

For you php error check 为您的PHP错误检查

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

You can check any kind of your javascript error by inspect your browser and go to your console and debug with console.log 您可以通过检查浏览器来检查任何类型的javascript错误,然后转到控制台并使用console.log进行调试

Hope this will help you 希望这个能对您有所帮助

  1. open Developer Tools 打开Developer Tools

  2. Go to Network tab 转到Network标签

在此处输入图片说明

try to look for 'comments.php' ... If 'comments.php' appears in red text, it means the url you provide is returning ERROR (or the URL is invalid) 尝试查找'comments.php' ...如果'comments.php'red文本显示,则表示您提供的网址返回错误(或网址无效)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Fullpage js 在本地主机上工作正常但不在实时服务器中 - Fullpage js working fine localhost but not in live server javascript mqtt websocket 在 localhost 中工作正常,在 https 服务器中工作正常 - javascript mqtt websocket works fine in localhost, not working in https server fullcalendar在localhost中工作正常,但在服务器中工作不正常 - fullcalendar is working fine in localhost but not in server $ .post和AJAX不能在服务器上运行,但在localhost中工作正常 - $.post & AJAX is not working on server, but working fine in localhost Javascript 不能在 localhost 上运行,但它可以在 Live 站点上运行 - Javascript not working on localhost, but it is working on Live site Ajax请求php在localhost上工作,但不在实时服务器上 - Ajax request to php working on localhost but not on live server Jquery-ui在Firefox中的localhost上可以正常工作,但在服务器上却不能? - Jquery-ui working fine on localhost in Firefox but not on server? 图像未显示在服务器上,但在节点 js 中的 localhost 上工作正常 - Images not showing up on server but working fine on localhost in node js jQuery无法在本地主机上的服务器上正确加载 - jquery is not loading properly on server within localhost working fine Javascript setInterval可在localhost上运行,但不能实时运行 - Javascript setInterval working on localhost but does't work on live
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM