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 微信会员卡接入微信支付商户号收款
    • ¥15 如何获取烟草零售终端数据
    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?