Искам да направя 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="/bgReadThought.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;
}
Проверих регистрационните файлове на конзолата и мрежата. Дава тази грешка. Мрежов регистър
Дебъгерът не достига до метода. Не мога да продължа.