Ajax and PHP?

0 favourites
  • 3 posts
From the Asset Store
Paypal PHP Supports multiple platforms, Web/html5 Android, IOS. (Including storing transaction data)
  • im trying to make a simple ajax chat room in construct. the problem is that i keep getting an error when i try to send the post data. the php file is on my website and im running the layout in preview. i think the problem is that my browser doesnt allow cross domain post data transfer. how can i test it locally. do i put the php file in the same folder as the

    capx file and run my my apache server or do i run the php file on the server and just put in the url im realy stuck guys please help.

    spud2451

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • What I would do is export the project as a "completed" game into wherever your php file is being kept, and then test it that way.

    So export the project to C:/xampp/htdocs/phpfilefolder/ or wherever it may be.

    Edit: Now you MAY also be able to (haven't tested it) but try to change the "preview server" in the preferences to localhost/foldername with foldername being what your folder is in the htdocs folder, assuming you are using xampp. foldername should be the name you use to connect to your webpage locally.

  • It's a cross domain issue. There is a way around it, but you open yourself up to potential misuse by doing so.

    You can setup the headers at the beginning of your php file to allow any domain (or specific domains) to access the php script.

    Personally, I setup my ajax call to send a variable called "key" and the script will look for the key variable and if it sees it, it added the header. If it doesn't, it just does things normally so calls from the same domain still work.

    Do a Google search for cross domain ajax php header to find out more info on how to set it up. If you still have issues with it, I might be persuaded to write a tutorial like I did for the Highschore table without a plugin via php/ajax that's on my site if I have time this week.

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