HTML_2.ajax遞交數據

 $.ajax({
                type: "POST",
                url: "/Login/Loginin",
                contentType: "application/json;charset=utf-8",
                data: JSON.stringify(data),
                dataType: "json",
                success:function (message) {
                    if (message.code == 200) {
                        layer.msg('登錄成功', function () {
                            window.location = '/main.html';
                            return true;
                        });
                    }else {
                        layer.msg('登錄失敗'+JSON.stringify(message.message), function () {
                            return false;
                        });
                    }

                },
                error:function (message) {
                      alert("提交失敗"+JSON.stringify(message));
                    return false;
                }
            });
JSON.stringify(data)將對象序列化成json
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章