dpmopn8542 2017-02-08 05:32
浏览 97

当我在另一个PHP文件中包含<script>标记时,javascript代码无法正常工作

I've been stuck on this issue for a while now. Maybe some of you programming geniuses can help me out.

So I am working with 6 files:

  1. BASE_URL/header.php
  2. BASE_URL/footer.php
  3. BASE_URL/includes/notifications.php
  4. BASE_URL/includes/wall.php
  5. BASE_URL/javascript1.js
  6. BASE_URL/javascript2.js

    The header.php file includes the tag for javascript1.js.

    The footer.php file includes the tag for javascript2.js.

    The notifications.php file gets the messages and alerts and has some html in it and calls a function from the wall.php.

    The wall.php file gets the messages from the database and has some html in it.

    The javascript1.js file has some ajax that refers to the notifications.php

    The javascript2.js file has some javascript.

Everything works fine. Except that the javascript code in my javascript2.js file doesn't seem to be working. And when I include the tag within the notifications.php file it causes some errors please help.

Here is the code for the javascript1.js

/*---------------- popoup message notifications -----------------*/
jQuery(document).ready(function()
{/* this function will be available after the document is loaded */

    /* declare the message notification variables */
    var messagesIcon    = $('.page_header_messages_icon');
    var messagesInboxList   = $('.messages_popup_box_inbox_list');

    /* declare the ajaxAutoAlerts variable */
    var ajaxAutoAlerts;

    /* call the autoLoadMessages function */
    autoLoadMessages();

    messagesIcon.click(function(event)
    {/* when the messagesIcon is clicked */

        /* show the ajax loader */              
        jQuery(messagesInboxList).html("<div class='load_notifications' align='center'><img src='"+site_url+"img/ajax-loader.gif' /></div>"); 

        var dataString = 't=alrt';

        jQuery.ajax({
            type: "POST",
            url: site_url+"includes/message_notifications.php",
            data: dataString,
            cache: false,
            success: function(response){

                jQuery(messagesInboxList).html("");
                jQuery(messagesInboxList).html(response);

                /* resize nicescroll everytime an element using nicescroll is shown/hidden */ 
                niceScrollVariable.getNiceScroll().resize();
            }
        });
    });
});
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
    • ¥15 微信公众号自制会员卡没有收款渠道啊
    • ¥15 stable diffusion
    • ¥100 Jenkins自动化部署—悬赏100元
    • ¥15 关于#python#的问题:求帮写python代码
    • ¥20 MATLAB画图图形出现上下震荡的线条
    • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
    • ¥15 perl MISA分析p3_in脚本出错
    • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
    • ¥15 ubuntu虚拟机打包apk错误