【问题标题】:Issue with running $.ajax in IE and firefox在 IE 和 firefox 中运行 $.ajax 的问题
【发布时间】:2013-02-11 16:55:20
【问题描述】:

大家好,我正在使用 chrome,并使用 JQuery UI 开发了一个开窗器,它运行良好。在 IE 和 Firefox 中我注意到它不起作用,我在 IE 中进行了调试,它说

 `SCRIPT1028: Expected identifier, string or number`

function sendUserfNotes()
    {

        $.ajax({
        type: "POST",
        dataType: "json",
        url: '/pcg/popups/getNotes.php',
        data:
        {
            'nameNotes': notes_name.text(),

        },<!-- gave me the error right here?

        success: function(response) {
            $('#notes_msg').text(response.the_notes);
        }
    });

不知道为什么,但这是我的脚本:

$(document).ready(function () { // this right here will wait to see if the 'access notes is clicked, if so then it will get te value of username and send it to run()
    $(".NotesAccessor").click(function () {
        notes_name = $(this).parent().parent().find(".user_table");

      run();
    });

    });
function run(){ // defines the place to get the notes, goes to showURL...() to open the JQuery dialog and than senduse....() to display them in the dialog.  
    var url = '/pcg/popups/grabnotes.php';

    showUrlInDialog(url);
    sendUserfNotes();


}
    function showUrlInDialog(url)
    {
      var tag = $("#dialog-container");
      $.ajax({
        url: url,
        success: function(data) {
          tag.html(data).dialog
          ({
              width: '100%',
                modal: true
          }).dialog('open');
        }
      });
    }
    function sendUserfNotes()
    {

        $.ajax({
        type: "POST",
        dataType: "json",
        url: '/pcg/popups/getNotes.php',
        data:
        {
            'nameNotes': notes_name.text(),

        },
        success: function(response) {
            $('#notes_msg').text(response.the_notes);
        }
    });

    }
    function getNewnotes(){
        new_notes = $('#notes_msg').val();
        update(new_notes);  
    }
    // if user updates notes
    function update(new_notes)
    {

            $.ajax({
        type: "POST",
        //dataType: "json",
        url: '/pcg/popups/updateNotes.php',
        data:
        {
            'nameNotes': notes_name.text(),
            'newNotes': new_notes,  
        },
        success: function(response) {
            alert("Notes Updated.");
            var i;
             $("#dialog-container").effect( 'fade', 500 );

            i = setInterval(function(){
             $("#dialog-container").dialog( 'close' );
            clearInterval(i);
            }, 500);

            }
    });

    }
    /******is user closes notes ******/
    function closeNotes()
    {
        var i;
         $("#dialog-container").effect( 'fade', 500 );

        i = setInterval(function(){
         $("#dialog-container").dialog( 'close' );
        clearInterval(i);
        }, 500);

    }

如果您能帮帮我,我将不胜感激 :) 不确定出了什么问题以及为什么它只能在 Chrome 中工作?如果您需要任何东西,请告诉我。

大卫

【问题讨论】:

  • 它给你的错误实际上就在这里'nameNotes': notes_name.text(), &lt;_--。尾随逗号对于破坏 IE 具有历史意义。不过我不知道FF....
  • 您在 Firefox 中遇到什么错误?
  • 你对IE有效的权利,FF呢?
  • 使用 Firebug 或直接打开控制台。
  • 你为什么这样使用setInterval(只让它触发一次)?你知道setTimeout,不是吗?

标签: javascript jquery jquery-ui internet-explorer jquery-ui-dialog


【解决方案1】:

data: { 'nameNotes': notes_name.text(), },

这是一个奇怪的问题,但在text() 之后删除逗号。这应该会有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-04-23
    • 1970-01-01
    • 2018-01-30
    • 1970-01-01
    • 2018-07-09
    • 2014-11-25
    • 2015-10-07
    相关资源
    最近更新 更多