ASK FOR HELP IN AJAX (CROSS DOMAIN)

0 favourites
  • 6 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • i still can't figure out how to get data from server (maybe cause the client and server are not in the same server!! but i do not know how to handle it)... when i use javascript below it works!!

    ...

    but when i use the ajax plugin it return error?? can anyone help me ....it has confused me so much....

  • function get_data(name,value) {$.ajax({

               type : 'get',

               async:false,

               url : 'h..t..t..p..:/../..1..1..5.28.160.34:2011/play_pie',

               data: ''+name+'='+value+'',

               dataType : 'jsonp',

               jsonp: 'jsoncallback',

               success : function(json){alert('sucess!!!'+json.data.number.one)},

               error:function(){      

                    alert('fail');

               }});

    }

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • If you are calling a PHP file through ajax on another host, add somewhere at the top:

    header('Access-Control-Allow-Origin: *');

    This will allow PHP to perform cross domain requests.

  • THANK U! but i still can't understant it... how to add 'header('Access-Control-Allow-Origin: *'); ' and my server file written in python,

       and this is image is in Construt2 <img src="ht_tp://dgardener.duapp.com/img/23.png" border="0" />

    it doensn't work

       this is in Javascript test it can get data..<img src="ht_tp://dgardener.duapp.com/img/12.png" border="0" />

  • SORRY I'm not allow to submmit URL please remove '_' below and you can see my images

    ht_tp://dgardener.duapp.com/img/23.png

    ht_tp://dgardener.duapp.com/img/12.png

  • For python add:

    self.response.headers['Access-Control-Allow-Origin'] = '*'

    Anywhere in your handler. (within your python script)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)