0

In coffeescript, I'm using this to load a json file

  $.ajax 'json/data.json',
        success  : (res, status, xhr, data) ->
            console.log("yea "+data)
        error    : (xhr, status, err) ->
            console.log("nah "+err)
        complete : (xhr, status) ->
            console.log("comp")

file loads but data comes up is undefined?

1
  • are you sure server is sending back any data? Commented Jan 17, 2013 at 7:15

1 Answer 1

1

Success takes different set of arguments:

success
Type: Function( Object data, String textStatus, jqXHR jqXHR )

Try this:

$.ajax 'json/data.json',
        success  : (data, status, xhr) ->
            console.log("yea "+data)
        error    : (xhr, status, err) ->
            console.log("nah "+err)
        complete : (xhr, status) ->
            console.log("comp")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.