Я хочу сделать ajax-вызов VUE.JS, который можно сделать с помощью 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>
Это был мой HTML-код, а теперь, как указано ниже, JS-код.
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 + '"',
{
headers: {
'Content-type': 'text/xml; charset=\"utf-8\"'
},
}, function (data) {
alert(data);
}).then(function (response) {
console.log(response);
}).catch(function (error) {
console.log(error);
});
}
}
});
Это мой код позади метода:
[WebMethod]
public static bool InsertThoughtMethod(string Thought)
{
return true;
}
Я проверил консольные и сетевые журналы. Выдает эту ошибку. Журнал сети
Отладчик не доходит до метода. Я не могу двигаться дальше.