Mokus
Mokus

Reputation: 10410

Fetching data through ajax using jQuery

I have two pages in different server.

Through ajax I would like to include some data: here is an example: link

The link is working through browser.

jQuery(window).ready(function() {
    getPageWithAjax("http://www.betcatcher.com/index.php?page=valuebets&nr_row=6");
    function getPageWithAjax(page)
    {        
        //alert(page)
        ajaxRequest = $.ajax(
                    {
                        url: page, 
                        cache: false,
                        success: function(msg){ajaxResponse(msg)},
                        error: function(msg){ajaxResponse('Error loading data.'+msg.status)} 
                    });    
    }
    function ajaxResponse(msg)
    {
        $("#live_bet_ajax_content").html(msg);
    }

});

But I'm getting error when I'm trying to get data.

Upvotes: 0

Views: 824

Answers (2)

JercSi
JercSi

Reputation: 1047

I assume, that you call script from different domain. You should use JSONP which supports cross-domain calls. Read this article how to do this.

Upvotes: 3

NickD
NickD

Reputation: 2646

looks to me like a Same-Origin Policy problem. For new browsers you could enable Cross-Origin Resource Sharing (CORS) http://enable-cors.org/ for old browser you probably need to build a serverside proxy which rewrites the requests.

Upvotes: 0

Related Questions