비동기식 양식 제출

4087 단어 양식 제출
        //  

        add_sale_info: function () {

            // 

            if (this.in_syncing) {

                return;

            }

            var current_view = this;

            this.in_syncing = true;

            // url

            var return_url = '/order/list/';

            // url

            var sale_url = '/order/add/sale/'+$('#id_pk').val()+'/info/';

            // 

            var sale_info = { sale_price : $('#id_sale_price').val(),

                        sale_cost_price : $('#id_sale_cost_price').val(),

                        sale_bonus_price: $('#id_sale_bonus_price').val(),

                        tax_price: $('#id_tax_price').val(),

                        other_price: $('#id_other_price').val()

                        };

            // 

            $.ajax({

                type: "POST",

                url: sale_url,

                data: sale_info,

                success: function(data) {

                    if (data.error_code > 0) {

                        window.alert(data.error_msg);

                    }else {

                        // 

                        window.location.href = return_url;

                    }

                },

                error: function(){

                    window.alert(' , 。');

                },

                complete: function(){

                    // 

                    // 

                    current_view.options.parentView.trigger('finish_ajax_sync');

                    current_view.in_syncing = false;

              }

            });

           return false; // avoid to execute the actual submit of the form.

        },

좋은 웹페이지 즐겨찾기