Vue.js VUE-axios Post不工作

Vue.js VUE-axios Post不工作,vue.js,vuejs2,axios,Vue.js,Vuejs2,Axios,我想对VUE.JS进行ajax调用,这可以由axios完成。我正在从JS文件中调用这个函数,下面是代码,我到目前为止已经尝试过了 <div id="VueCalling"> <div class="container"> <label>Please enter thought </label> <input type="text" id="txtThought" clas

我想对VUE.JS进行ajax调用,这可以由axios完成。我正在从JS文件中调用这个函数,下面是代码,我到目前为止已经尝试过了

    <div id="VueCalling">    
        <div class="container">
            <label>Please enter thought </label>
        <input type="text" id="txtThought" class="form-control textboxCustm" v-model="textThought" />
        </div>
        <input type="button" class="btn btn-info" id="btnInsert" value="Insert JS" v-on:click="greet" />
        <br />
        <br />

        <a href="ReadThought.aspx" class="btn btn-primary">Read all thoughts</a>
    </div>
</asp:Content>
这是我的代码隐藏方法:

[WebMethod]
    public static bool InsertThoughtMethod(string Thought)
    {
        return true;
    }
我已经检查了控制台和网络日志。它给出了这个错误。


调试器在到达方法之前不会到达。我不能再往前走了。

我研究了这段代码并找到了解决方案。下面的代码运行良好。我查过了

new Vue({
el: '#VueCalling',
data: function () {
    return {
        textThought: null,
        checkbox: null,
        text: null,
    }
},
methods: {
    greet: function (event) {
        // `this` inside methods points to the Vue instance
        var passedEmail = this.textThought;

        // `event` is the native DOM event
        axios.post('Default.aspx/InsertThoughtMethod', { Thought : passedEmail }).then(function (response) {
    console.log(response);
}).catch(function (error) {
    console.log(error);
});
    }
}
});

是否执行了greet方法?(您可以添加控制台日志)。然后打开浏览器开发工具,检查单击是否发送http post。并告诉我们服务器的响应。(404,跨站点脚本,…)与其不起作用,不如提供更详细的解释。在调试ajax请求时,通常需要检查以下细节:请求是否首先发送,如果是,状态代码是什么。如果您在控制器上设置了断点,您是否在那里收到请求?请原谅。我编辑了问题并添加了更多细节500表示“内部服务器错误”。因此,您的axios POST请求没有问题。你应该检查你服务器的日志。嘿@puelo。。是的,你说得对。但问题是,我在目的地有一个kep调试器,但它并没有到达目的地。没有到达那里,它就付出了500英镑
new Vue({
el: '#VueCalling',
data: function () {
    return {
        textThought: null,
        checkbox: null,
        text: null,
    }
},
methods: {
    greet: function (event) {
        // `this` inside methods points to the Vue instance
        var passedEmail = this.textThought;

        // `event` is the native DOM event
        axios.post('Default.aspx/InsertThoughtMethod', { Thought : passedEmail }).then(function (response) {
    console.log(response);
}).catch(function (error) {
    console.log(error);
});
    }
}
});