user3488168 user3488168 - 2 months ago 13
Ajax Question

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. here i have created JS function to check whether passing URL working proper or not.
kindly help me.

<script type="text/JavaScript">
type: "GET",
dataType: "jsonp",
url: "",
success: function(data){


You cannot do a cross domain call using ajax. what you can do is to do a php call like :

$website = file_get_contents('');

and store it in a text file and access that using your ajax on your server using the same ajax file you have.

i had similar case that i had a php call on scheduler to grab text from url every minute and update a json file. then simply use :

$.getJSON( "ajax/test.json", function( data ) {
 //your function

or use ajax! whichever you fancy