Z
Z
Zaur Ashurbekov2014-04-30 21:58:47
JavaScript
Zaur Ashurbekov, 2014-04-30 21:58:47

Why is the ajax request not being executed?

Hello Habr!
There is a link

= link_to "Редактировать", id: "load_formForItem", data: {ajax_path: :getFormForEditItems}


there is a code that should handle the event
$ ->
  $('#load_formForItem').click ->
    projects_path = $('#load_formForItem').data('ajax-path')
    $.ajax projects_path,
      type: 'POST'
      dataType: 'script'


but the problem is that nothing happens. The console is silent. What could be the problem?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
Cepega, 2014-04-30
@zaurius

= link_to "Редактировать", '#', id: "load_formForItem", data: {ajax_path: :getFormForEditItems}

Notice I've inserted a second argument in link_to. Otherwise, id will be used not as an id, but as an address.

A
Arkady Butermanov, 2014-04-30
@Arkadey

You, apparently, have a typo: you pass ajax_path to the helper, in JS you use ajax-path

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question