0

当我提交表单时,我将序列化对象发送到服务器。但在发送之前,我需要将其所有输入元素大写。

这是我的一段代码:

submitForm: function(e) {
    e.preventDefault();
    var data = Backbone.Syphon.serialize(this);
    console.log(data);// here i need to uppercase all data elements
    this.trigger("form:submit", data);
},

我需要在将其发送到 thserver 而不是在后端之前执行此操作。有什么解决方案可以建议吗?

4

1 回答 1

0

如果data是一个对象数组,您需要迭代每个对象并使用方法toUpperCase(),例如:

$.each(data, function(index, value){
    console.log(value.toUpperCase());
});
于 2016-03-15T13:49:06.270 回答