Trying to display a string from a website through an jQuery AJAX request. However no matter what, I'm always getting an error.
I have a HTML form:
<form name="algoDico" action="" onsubmit="return buttonClicked()">
Mot: <input type="text" name="mot" id="mot">
<input type="submit" value="Submit">
</form>
and my Javascript:
var buttonClicked = function () {
var w = $('#mot').val();
$.ajax({
type: "GET",
url: "http://www.igrec.ca/project-files/wikparser/wikparser.php",
dataType: "text",
data: {
word: w,
query: "def",
count: 1,
lang: "fr",
},
success: function(data) {
console.log(data);
},
error: function(){
console.log(w);
console.log("error");
}
});
}
I wish to retrieve the text from this website (eg url: http://www.igrec.ca/project-files/wikparser/wikparser.php?word=manger&query=def&count=1&lang=fr )
Yet I keep getting : "error"
Thanks
Here are some useful resources to make cross domain requests:
http://www.webdevdoor.com/jquery/cross-domain-browser-json-ajax/
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.