ajax数据获取与传送

时间:2021-06-02 16:53:42
function service_ajax(){
var migrate_style = $('#myTab').find('.active').attr('value'); //jquery获取页面数据
var migrate_text = $('#myTabContent').find('.service-textarea').val();
var user = "{{ current_user.email }}"
var url = "{{ url_for('api.new_service_modify') }}";//后台接口
var service_id = "{{ request.path|service_filter_count}}";
$.ajax({
type:
"post",
url: url, //后台接受数据的url
contentType:
"application/json; charset=utf-8",
dataType:
"json",
data: JSON.stringify({ //要传给后台的数据
"modify_user": user,
"migrate_style": migrate_style,
"migrate_text": migrate_text,
"service_id": service_id
}),

success:
function (msg) {
toastr.success(
'添加变更记录成功,页面即将刷新')//在页面上显示的提示信息
setTimeout(function () {
window.location.reload();
},
1000);
},
error:
function (XMLHttpRequest, textStatus, errorThrown) {
toastr.error(
'添加变更记录失败')


}

});
}