I am sending data to a specific URL and then I try to get it with ajax it just prints up an error
<script type="text/javascript" src="{{ url_for('static', filename='jquery.js') }}"></script>
<script>
$(document).ready(function()
{
$.ajax({
method: "POST",
url: "/computers/{{id}}",
dataType: "json",
async: true,
succsess: function(data){
var json = $.parseJSON(data); // create an object with the key of the array
alert(json.html);
console.log(data)
},
error: function(error){
console.log("Error:");
console.log(error);
}
});
});
</script>
^ that's how I receive the request (the id is 2)
The problem was that I am not sending any data but I am also typing that dataType: "json"
So that made the error.
$.ajax({
method: "POST",
url: "/computers/{{id}}",
async: true,
succsess: function(data){
var json = $.parseJSON(data); // create an object with the key of the array
alert(json.html);
console.log(data)
},
error: function(error){
console.log("Error:");
console.log(error);
}
});
So this is the correct code because I am not sending any data.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.