Using CoffeeScript in a Rails 3 app I have a simple ajax call:
$(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"))
This call works fine in Chrome and Safari but not the above browsers.
I tried putting an alert in the complete function and the function is just not getting called at all in FF, IE or Opera.
Any ideas??
Revisited this after a couple of months as it wasn’t high priority.
Turns out it was a simple typo. Doh!
It was the
}in this line$("#photo-wrapper > img}").attr("src", result.photo.player.url)I guess chrome is a bit more forgiving than firefox.