0

So I have an ajax request that works fine when I just put the file name ex:

var security = function(){
    var link = $('#chosen').attr('href');
        $.get('func.php',function(result)         {
            if (result > 75 && result % 5 === 0){
                    $('#chosen').attr("href", link);


            }else{
             $('#chosen').attr('href','https://www.google.com');

            }
        });
        $("#chosen").click(function(){
            $.get('func2.php',function(results){
            if (results === results){
                location.reload();
            }
        });
        });
        $("#chosen").click(function(){
            $.get('func3.php',function(results){
            if (results === results){

            }
        });
        });
};

I wanna make the func.php functions recheable from anywhere so i havean url named cligit.com i tried linking it like thisbut when i do that it stops working

var security = function(){
    var link = $('#chosen').attr('href');
        $.get('http://www.vanillacomp.com/browse/func.php?callback=?func.php',function(result)         {
            if (result > 75 && result % 5 === 0){
                    $('#chosen').attr("href", link);


            }else{
             $('#chosen').attr('href','https://www.google.com');

            }
        });
        $("#chosen").click(function(){
            $.get('http://www.cligit.com/func2.php',function(results){
            if (results === results){
                location.reload();
            }
        });
        });
        $("#chosen").click(function(){
            $.get('http://www.cligit.com/func3.php',function(results){
            if (results === results){

            }
        });
        });
};
BenMorel
  • 34,448
  • 50
  • 182
  • 322

1 Answers1

0

Add these to headers in your func.php page

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');

Hope this helps,Thank you

SarathSprakash
  • 4,614
  • 2
  • 19
  • 35