Javascript在本地工作,但在服务器上运行时会中断

Javascript在本地工作,但在服务器上运行时会中断,javascript,Javascript,我想不出是什么问题。有人能帮忙吗?您的comments/submit.php参数没有指向服务器上的正确位置。在您的本地环境和生产服务器中,将对运行它的URL进行某种类型的修改 在Chrome的“调试”菜单或其他浏览器中的类似菜单中查看您的“网络”选项卡,以查看它试图去哪里 最有可能的是,解决方案很简单,只需在帖子路径的前面添加一个/即可,但URL链中可能还有一两步您没有完成。控制台中有错误吗?请将它们添加到您的问题中。所有这些都在客户端运行,无论从何处提供服务。可能的问题是comments/su

我想不出是什么问题。有人能帮忙吗?

您的comments/submit.php参数没有指向服务器上的正确位置。在您的本地环境和生产服务器中,将对运行它的URL进行某种类型的修改

在Chrome的“调试”菜单或其他浏览器中的类似菜单中查看您的“网络”选项卡,以查看它试图去哪里


最有可能的是,解决方案很简单,只需在帖子路径的前面添加一个/即可,但URL链中可能还有一两步您没有完成。

控制台中有错误吗?请将它们添加到您的问题中。所有这些都在客户端运行,无论从何处提供服务。可能的问题是comments/submit.php-您是否查看了浏览器网络检查器以验证请求/响应以检查其是否符合预期?找到了问题!你是对的,它在submit.php中
$(document).ready(function(){
/* The following code is executed once the DOM is loaded */

/* This flag will prevent multiple comment submits: */
var working = false;

/* Listening for the submit event of the form: */
$('#addCommentForm').submit(function(e){

    e.preventDefault();
    if(working) return false;

    working = true;
    $('#submit').val('Working..');
    $('span.error').remove();
    console.log('Test javascript 1')
    /* Sending the form fileds to submit.php: */

    $.post('comments/submit.php',$(this).serialize(),function(msg){
    console.log('Test javascript 2')
        working = false;
        $('#submit').val('Submit');

        if(msg.status){

            /* 
            /   If the insert was successful, add the comment
            /   below the last one on the page with a slideDown effect
            /*/

            $(msg.html).hide().insertBefore('#addCommentContainer').slideDown();
            $('#body').val('');
        }
        else {

            /*
            /   If there were errors, loop through the
            /   msg.errors object and display them on the page 
            /*/

            $.each(msg.errors,function(k,v){
                $('label[for='+k+']').append('<span class="error">'+v+'</span>');
            });
        }
    },'json');

});
$.post('comments/submit.php',$(this).serialize(),function(msg){