Skip to content

dataType doesnt work? #699

Description

@max-degterev

Hi! Having a bit of a problem here

@_req = $.ajax(
  url: app.api('suggest', place)
  dataType: 'json'
  success: _.bind(@renderSuggest, @)
  error: _.bind(@clearSuggest, @)
)

works when

@_req = $.ajax(
  url: app.api('suggest', place)
  success: _.bind(@renderSuggest, @)
  error: _.bind(@clearSuggest, @)
)

doesnt. Server headers are fine, getting unparsed string response from the server anyway.

Tried this as a workaround:

app.dom.doc.on('ajaxBeforeSend', (e, xhr, options)->
  options.dataType = 'json' unless options.dataType
)

Doesnt work either. options already have dataType == 'json'

Activity

  1. mislav commented on Feb 19, 2013

    @mislav
    Collaborator

    What is the Content-type of server response? Is it "application/json"? If it's not, you have to explicitly set dataType in order to have JSON automatically parsed

  2. max-degterev commented on Feb 19, 2013

    @max-degterev
    Author

    Running server with node, expressjs

    dataType set:
    Screen Shot 2013-02-19 at 8 10 25 PM

    dataType not set:
    Screen Shot 2013-02-19 at 8 11 37 PM

    (note the Accept:/)

  3. mislav commented on Mar 3, 2013

    @mislav
    Collaborator

    Thanks! It should work now. In your case, things should work even without dataType specified explicitly

  4. added a commit that references this issue on Apr 24, 2013
    eeab317
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions