XHR加载失败:POST [英] XHR failed loading: POST

查看:1331
本文介绍了XHR加载失败:POST的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我试图用ajax发布,但是它不会通过.

so I am trying to post with ajax, and it just wont go through.

这是我的JavaScript

here is my javascript

$.ajax({
      type: 'POST',
      contentType: "",
      url: 'some url',
      data: order,
      dataType: 'json',
      success: function() {
        Materialize.toast('Order added successfully', 4000, 'android-success');
        console.log('order posted');

      },


      error: function() {
        Materialize.toast('Something went wrong', 4000, 'android-error');
      }

    }); // $.ajax post

我没有收到错误,也没有从ajax获得成功.但是我在XHR failed loading: POST

I am not getting an error nor am I getting a success from ajax. But I am getting a chrome console error listed above XHR failed loading: POST

我尝试将内容类型和数据类型设置为无效.我的猜测是,问题出在对象格式之类的东西上.

I have tried setting content type and data type to no avail. My guess, the problem is in the object format or something of that sort.

可能有用的信息- 这是我的代码的基本概述.

Probably useful information -- this is a basic outline of my code.

  1. 我有一个带有点击事件的按钮
  2. 在该函数中,我有if else语句
  3. 如果输入字段为空白event.preventdefault(),则单击按钮
  4. 其他ajax发布

这是失败日志下的信息

send    @   jquery-3.1.0.js:9392

ajax    @   jquery-3.1.0.js:8999

(anonymous function)    @   ajax.js:20

mightThrow  @   jquery-3.1.0.js:3508

process @   jquery-3.1.0.js:3576

在此问题上的任何帮助都感激不尽.

Any help on this matter really appreciated.

推荐答案

我可以使用它.问题在于页面重新加载.因此,在发布请求可以通过网页之前,将重新加载,这不会导致任何错误,而只会导致日志失败. gh,这样的菜鸟错误.

I got it to work. The problem was with the page reloading. So before the post request could go through the web page would reload which resulted in no error but just a failed log. Ugh, such a rookie mistake.

这篇关于XHR加载失败:POST的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆