[英]how to consume data from rest api using ajax jquery
i am new in j query ajax.i don't have idea how to fetch data from rest API using j query ajax.
我是j查询ajax的新手。我不知道如何使用j查询ajax从rest API获取数据。 here i have created JS function to check whether passing URL working proper or not.
在这里,我创建了JS函数来检查传递的URL是否正常工作。 kindly help me.
请帮助我。
<script type="text/JavaScript">
$.ajax({
type: "GET",
dataType: "jsonp",
url: "https://www.propertyfinder.ae/en/find-broker/ajax/search?page=1",
success: function(data){
alert(data);
}
});
</script>
You cannot do a cross domain call using ajax. 您不能使用ajax进行跨域调用。 what you can do is to do a php call like :
您可以做的是像这样进行php调用:
$website = file_get_contents('http://google.com');
and store it in a text file and access that using your ajax on your server using the same ajax file you have. 并将其存储在一个文本文件中,然后使用您拥有的相同ajax文件在服务器上使用ajax访问该文本。
i had similar case that i had a php call on scheduler to grab text from url every minute and update a json file. 我有类似的情况,我在调度程序上有一个php调用,每分钟从URL抓取文本并更新json文件。 then simply use :
然后只需使用:
$.getJSON( "ajax/test.json", function( data ) {
//your function
});
or use ajax! 或使用ajax! whichever you fancy
随你便
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.