0 Favourites

How do I obtain last data with Ajax Object in local ?

  • Hello,

    I'm new with Construct 2 and i try to use Ajax Object on my project. Sorry if my english is bad, I'm french .

    I have follow this tutorial : and i have problem when i would print data from my Ajax Request. I'm working on local network.

    I have created a Sprite and when i click on it, i launch Ajax Request to get data from a file. My Ajax request completes successfully but I can't recover the data. I tried to display the data in a field "Text" with AJAX.LastData property but nothing appears. By changing the field "Text" with an arbitrary value, the change is made ​​when the Ajax request completes.

    I activated the Access-Control-Origin on my browser. If I get the address of the file directly in my browser, the text is displayed correctly.

    My file contain : "I'm a test file" but nothing is displayed on "Text" Field.

    Have you an idea of what can block?

    Thank you in advance,

  • When the AJAX Object has no Data, I guess the request was not successful.

    Which browser are you using? Maybe you can open developper tools (F12 in every browser, in FF you need to install FireBug) and see if the request was successfull.

  • Hello,

    I'm using Firefox and i have installed Firebug. I attach a screenshoot of my request.

    When I entered the address into my browser: I get well "I'm a test file."

    When I look at the response tab of Firebug, it is empty despite a response "200 OK" visible on screenshoot.

    Someone should track?

    Thank you in advance

  • Do you use Ajax request or Ajax post?

    Is the file in localhost/construct/ajaxExampleGet.php?

    What does ajaxExampleGet.php do?

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Hello I'm using Ajax Request not Ajax post.

    The file is in localhost/construct/ajaxExampleGet.php and i can access to him by enter the adress in my browser.

    ajaxexampleGet.php only display a message. There are not yet php just text.

  • May I see your c2 code?

    And try to make an AJAX request to a random site (like google.com) and see if this is working.

  • I have the same problem with an adress like google.com. The response is empty. I don't see what can blocking request.

    My c2 code is in attachment.

    Thanks for your help.

  • There must be something wrong with your localhost.

    When I type in this adress: http://ip.jsontest.com/ its working.

    You response also has to be a string as far as I know.

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