调试jquery处理程序

这个问题是这个问题的后续问题。 我创建了一个简单的示例来检查代码在处理程序中的执行方式。 对于表格

Insert date:

我正在尝试使用以下javascript检索字段:

 function get_form_data_uid($form) { var unindexed_array = $form.serializeArray(); var indexed_array = {}; $.map(unindexed_array, function (n, i) { indexed_array[n['name']] = n['value']; }); indexed_array['uid'] = 'badbfadbbfi'; return indexed_array; } $("#calendar_id").submit(function (e) { var uri, method, formId, $form, form_data; // Prevent default submit e.preventDefault(); e.stopImmediatePropagation(); uri = "/"; method = "POST"; formId = "#calendar_id"; $form = $(formId); form_data = get_form_data_uid($form); alert("form_data " + form_data); // Set-up ajax call var request = { url: uri, type: method, contentType: "application/json", accepts: "application/json", cache: false, // Setting async to false to give enough time to initialize the local storage with the "token" key async: false, dataType: "json", data: form_data }; // Make the request $.ajax(request).done(function (data) { // Handle the response // Attributes are retrieved as object.attribute_name console.log("Data from change password from server: " + data); alert(data.message); }).fail(function (jqXHR, textStatus, errorThrown) { // Handle failure console.log(JSON.stringify(jqXHR)); console.log("AJAX error on changing password: " + textStatus + ' : ' + errorThrown); }); }); 

但是,处理程序中的代码未执行(警报未显示)。 为什么?

编辑:

代码工作jsfiddle但不在Firefox中。

至少,您正在调用函数get_form_data_with_token() ,该函数未在您发布的代码中的任何位置定义。 也许你打算调用你的get_form_data_uid()

本来只是作出评论,但显然不能。