Jquery load url with ajax

前端 未结 3 1984
北恋
北恋 2021-01-26 10:13

I\'m trying to automatically run an ajax url when my page is fully loaded using .load() function. It seems my code doesn\'t work.

Other information:

<
相关标签:
3条回答
  • 2021-01-26 10:25

    Please check the error in your browser console

    Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://shareasale.com/sale.cfm?amount=99.00&tracking=15&transtype=sale&merchantID=49748. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

    0 讨论(0)
  • 2021-01-26 10:38

    I am really puzzled why you need to load a tracking pixel via Ajax:

    I used to work in SEO and we would just include the link to the tracking pixel in an image e.g. via

    <img src="https://shareasale.com/sale.cfm?amount=99.00&tracking=15&transtype=sale&merchantID=49748" width="1" height="1">.

    Then you have no cross domain issues, no ajax, no worries.It just records on their site that the page loaded has your affiliate code (and probably drops a cookie at the same time).

    0 讨论(0)
  • 2021-01-26 10:42

    This is completely working but just shows this error:

    XMLHttpRequest cannot load https://shareasale.com/sale.cfm?amount=99.00&tracking=15&transtype=sale&merchantID=49748. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access.

    This might not work from yout local host but will work properly from any server.

    And still there is any error try this code:

    $(document).ready(function(){
        $.ajax({
               url:'https://shareasale.com/sale.cfm?amount=99.00&tracking=15&transtype=sale&merchantID=49748',
               success:function(data)
                {
                    alert(data);
                }
            })
    });
    
    0 讨论(0)
提交回复
热议问题