Symfony:ajax调用在prod环境中工作,但在dev环境中不起作用

时间:2018-03-20 18:56:12

标签: javascript php jquery ajax symfony

在symfony 3中,我使用ajax根据文档中描述的第一个字段的值检索一些字段: https://symfony.com/doc/3.4/form/dynamic_form_modification.html#form-events-submitted-data

这是我的ajax代码:

<script>
  var $groupeCompetence = $('#requete_prestataire_groupeCompetence');
// When sport gets selected ...
$groupeCompetence.change(function() {
  // ... retrieve the corresponding form.
  var $form = $(this).closest('form');
  // Simulate form data, but only include the selected sport value.
  var data = {};
  data[$groupeCompetence.attr('name')] = $groupeCompetence.val();
  // Submit data via AJAX to the form's action path.
  $.ajax({
    url : $form.attr('action'),
    type: $form.attr('method'),
    data : data,
    success: function(html) {
      // Replace current position field ...
      $('#requete_prestataire_competence').replaceWith(
        // ... with the returned one from the AJAX response.
        $(html).find('#requete_prestataire_competence')
        );
            console.log("ok");
      // Position field now displays the appropriate positions.

    },
    error: function(xhr,status,error) {
      console.log(error));
    }
  });
});
</script>

我收到此错误消息:

  

TypeError:tbody.rows.count不是函数       at startAjaxRequest((index):173)       在XMLHttpRequest.open((索引):173)       at Object.send(jquery.js:9425)       在Function.ajax(jquery.js:9143)       在HTMLSelectElement。 ((指数):151)       在HTMLSelectElement.dispatch(jquery.js:5201)       在HTMLSelectElement.elemData.handle(jquery.js:5009)

我不明白的是,所有这些都在prod环境(/ web /)中有效但在开发环境中无效(/web/app_dev.php /)。

任何人都可以帮助我吗?

0 个答案:

没有答案