How do I use Ajax to get *new* values from XML

Get help using Construct 2

Post » Fri Feb 12, 2016 6:05 pm

I have an XML file which is updated at 4Hz with values from an external process. I have included this xml file into my project, and am attempting to show the constantly updating values in a text box. I have created a System object and set it to load the xml file twice per second, using the AJAX plugin. I then set up text boxes to display the XML values, using Ajax -> on XML completed. But the text boxes only show the initial value, and are not being updated with the subseqent values. What am I missing?
B
5
Posts: 6
Reputation: 239

Post » Fri Feb 12, 2016 6:46 pm

It could be that the XML file you update is not the same as the XML file in the project. What is this the update process looking like ?
B
69
S
28
G
24
Posts: 977
Reputation: 18,739

Post » Fri Feb 12, 2016 7:02 pm

Message: Maystaff can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
The xml file is being rewritten by an exe, which is picking up input from a hardware device. There is only one xml file of that name, which has been added to the project. I know it's seeing it because it's showing the initial value

event sheet image here: http://westernpath.com/maystaff/xml.png

Thanks for your input
B
5
Posts: 6
Reputation: 239

Post » Fri Feb 12, 2016 8:53 pm

Everything seems in order, it might be a caching problem client-side. Could you try adding a random parameter in your AJAX request? It would fool the caching mechanism into believing they are distinct request and actually execute them every time.
B
69
S
28
G
24
Posts: 977
Reputation: 18,739

Post » Fri Feb 12, 2016 9:27 pm

I wondered about cache. I'm new to Construct 2, how would I best achieve adding a random parameter? There's also cache: false you can use in jQuery, but I'm not sure how I'd implement it here
B
5
Posts: 6
Reputation: 239

Post » Fri Feb 12, 2016 9:47 pm

Don't use "request project file" and simply use the filename as the URL and add a query string to it. If using a post request, put the query string in the "data" box instead. Can't test it right now but it should work.
B
69
S
28
G
24
Posts: 977
Reputation: 18,739

Post » Sat Feb 13, 2016 7:21 pm

Missing link is to add AJAX -> On ANT completed -> System -> Reset persisted objects on event sheet. Not sure what this will do to other objects, but will post any updates. Thanks for the pointers @Magistross!
B
5
Posts: 6
Reputation: 239


Return to How do I....?

Who is online

Users browsing this forum: evillair, rbailey83, Solomon, vankizzle and 9 guests