How Import AJAX to a string, elegantly?

0 favourites
  • 11 posts
From the Asset Store
This collection of music is the beautiful performance of rather small strings ensemble (8 first violins, 6 second violin
  • I'm testing AJAX for a new project.

    When I import a simple string from a project file and use a Text Box and set TextBox.text to AJAX.LastData, it works fine.

    If I use a string variable, and say StringVariable = AJAX.LastData, the string ends up blank.

    FYI - When I import the AJAX to the textbox, then make the string equal the textbox.text, it works as well.

    So I suppose my questions are:

    1. What "variable type" is AJAX.LastData? (Seems like an object of some kind and not a string.)

    2. Any way to make this work without the XML Plugin?

    Thank you! The C2 community is the best!

  • Ajax.LastData is generally a textual string.

    If you have a Ajax request tagged: "getPage"

    On Ajax request done "getPage" set StringVariable = Ajax.Lastdata

    The Ajax.LastData needs to be called in the On ajax request done trigger. (or as a sub event)

  • thank you unfortunately, i a, aware of all that - and i don't see any way to tag an Ajax request in C2.

    https://www.scirra.com/manual/107/ajax.

    I'm just wondering what is the simplest way to get Ajax.Lastdata into a string?

  • thank you unfortunately, i a, aware of all that - and i don't see any way to tag an Ajax request in C2.

    https://www.scirra.com/manual/107/ajax.

    I'm just wondering what is the simplest way to get Ajax.Lastdata into a string?

    Did you take your time to read this ?

    Read the first thing that comes after "How to make a request".

    In your request, I believe its the last entry/option ... there you can add a TAG name.

    The info I gave you is what you are asking for.

  • Apologies. Yes, I see now. But tagging it is irrelevant to this.

    On Ajax request done "getPage" set StringVariable = Ajax.Lastdata

    That is precisely what I have done but the stringvariable ends up simply being empty.

    Why would it be empty? If I say textbox.text = ajax.lastdata, the text transfers easily.

    I can then say stringvariable = textbox.text to get the text in the string, but this seems roundabout.

    I'm wondering if there's a cleaner way that's all. Thank you for your time helping me figure this out.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • That is precisely what I have done but the stringvariable ends up simply being empty..

    Then either your request is incorrect, or your request does not get you anything.

    How do you know stringVariable is empty ? Did you check the debugger ?

  • Thanks again - yes, I checked debugger that's how I see the string is empty. I will post a capx later tonight and that should clarify my issue. Thanks for your help, mate!

  • There is no reason why it wouldn't work. AJAX.LastData is indeed a string. What device/browser are you using for your tests ? I just tested with Firefox and the "on complete" event sucessfully set my string variable to AJAX.LastData.

  • I am using Chrome. This is so weird. I just tried it again and it worked. Below is the code.

    Yesterday the text box that I was feeding the string turned up blank in the debugger and in the layout.

    Today it works completely as expected. I have no idea what changed between yesterday and today but I have no more questions... for now!

    Thank you lennaert and Magistross for your assistance!

  • The text object you're trying to show the string in is probably not big enough. The string variable is probably being set correctly.

  • The text object you're trying to show the string in is probably not big enough. The string variable is probably being set correctly.

    Did you take your time to read this ?

    I'm testing AJAX for a new project.

    When I import a simple string from a project file and use a Text Box and set TextBox.text to AJAX.LastData, it works fine.

    If I use a string variable, and say StringVariable = AJAX.LastData, the string ends up blank.

    Sorry Ashley, could not resist

    edit: it was solved already though

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