kreamik
kreamik

Reputation: 627

how to get ajax data with jquery?

i try using jquery ajax to get content from :

http://www.infovesta.com/isd/free/reksa2.jsp?tipe=pt&_=1332749661789

that url is contained data from h**p://www.infovesta.com/isd/index.jsp

after checking by firebug on my working page, i get http response 200 but data is not loaded,
but comparing to their site, they can get the data with that request url.

what's the step i missed?

my code :

<script>
$(document).ready(function(){
        $.ajax({
          url: 'http://www.infovesta.com/isd/free/reksa2.jsp?tipe=pt&_=1332749661789',
          success: function(data) {
            $('.result').html(data);
          }
        });     
}); 
</script>

Upvotes: 1

Views: 370

Answers (1)

Nicola Peluchetti
Nicola Peluchetti

Reputation: 76870

I think that you are calling another domain and you have a problem with same domain policy. Does that site support jsonp?If so you should do

 $.ajax({
      url: 'http://www.infovesta.com/isd/free/reksa2.jsp?tipe=pt&_=1332749661789',
      dataType: 'jsonp',
      success: function(data) {
        $('.result').html(data);
      }
    });     

Setting the dataType to jsonp does the following

Loads in a JSON block using JSONP. Adds an extra "?callback=?" to the end of your URL to specify the callback. Disables caching by appending a query string parameter, "_=[TIMESTAMP]", to the URL unless the cache option is set to true.

Upvotes: 1

Related Questions