Home > Web Front-end > JS Tutorial > body text

Detailed explanation of the error reported when the post method returns in Ajax

php中世界最好的语言
Release: 2018-04-02 13:48:39
Original
2055 people have browsed it

This time I will bring you a detailed explanation of the error reported when the post method returns in Ajax. What are the precautions when dealing with the error reported when the post method returns in Ajax. The following is a practical case, let's take a look.

This is the Node.js server

<pre style="font-family: 宋体; font-size: 9pt; background-color: rgb(255, 255, 255);"><pre name="code" class="javascript">$(".reg_code_btn").click(function(e){ 
  $(e.target).parent().children().first().val() 
  $.ajax({ 
    type:"POST", 
    url:"validate/vcode", 
    dataType:"json", 
    data:{ 
      vcode:"code" 
    }, 
    success:function(data){ 
      console.log(data); 
      alert(data); 
    }, 
    error:function(data){ 
      console.log(data); 
      alert("发生错误"); 
    } 
  }); 
});

 
 
 
 
调试结果如下:
Copy after login

## If we only look at our own code part, we will not find what we should questionable. But if we find during debugging that the error return values ​​returning an

object object all have the same commonality:

starts with 0

I Change the server's return value to JSON type and the above situation will disappear.

# I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

How to communicate data between C and View

What are the front-end and back-end types? ajax interaction method

The above is the detailed content of Detailed explanation of the error reported when the post method returns in Ajax. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!