【问题标题】:IE, Firefox, Opera not calling complete function in ajax callIE、Firefox、Opera 没有在 ajax 调用中调用完整的函数
【发布时间】:2012-09-12 23:15:25
【问题描述】:

在 Rails 3 应用程序中使用 CoffeeScript 我有一个简单的 ajax 调用:

$(document).ready ->

fetchProfile = (profile_id) ->

    fetchingProfile = null

    if fetchingProfile
        fetchingProfile.abort()

    fetchingProfile = $.ajax
        type: "GET"
        dataType: "json"
        url: "/api/profiles/" + profile_id
        cache: false
        timeout: 8000

        beforeSend: ->
            $("#loading-div").show()

        complete: ->
            $("#loading-div").hide()
            $("#info-box").show()

        success: (result) ->
            $("span#name").text(result.name)
            $("span#position").text(result.position)
            $("span#number").text("#" + result.number)
            $("span#experience").text(result.experience)
            $("span#nationality").text(result.nationality)
            $("span#height").text(result.height_feet + "' " + result.height_inches + "\"")
            $("span#age").text(result.age)
            $("span#weight").text(result.weight + "lbs")
            $("span#favteam").text(result.favourite_nfl_team)
            $("#photo-wrapper > img}").attr("src", result.photo.player.url)

        error: (result) ->
            if (result.statusText != "abort")
                $("#error").show()


$("a#fancybox-link").click ->
    $("a.profile-link").removeClass("selected")
    $(@).addClass("selected")
    fetchProfile($(@).data("profile"))

$("a#error-link").click (e) ->
    e.preventDefault
    fetchProfile($("a.selected").data("profile"), $("a.selected").data("user"))

此调用在 Chrome 和 Safari 中运行良好,但在上述浏览器中运行良好。

我尝试在完整函数中添加警报,但在 FF、IE 或 Opera 中根本没有调用该函数。

有什么想法吗??

【问题讨论】:

    标签: ajax internet-explorer firefox coffeescript


    【解决方案1】:

    几个月后重新审视它,因为它不是高优先级。

    原来这是一个简单的错字。呸!

    这是}这一行中的$("#photo-wrapper > img}").attr("src", result.photo.player.url)

    我猜 chrome 比 firefox 更宽容一点。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-23
      • 1970-01-01
      • 1970-01-01
      • 2020-07-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多