Execute an update action on page load

I know I am missing something since this is something very simple but when mind freezes…

I created an update action which gets two $_GET varialbles to indicate what to update. What I need is to execute the update when page loads, I need no trigger to execute the ServerConnect action. Added the ServerConnect action through AppConnect but it does not execute.

Any possible reason for that ServerConnect not executing when page loads?
Thank you!

Once the server action has been created, then you need to add the action o your page with app connect, and if you want it to fire on page load then just make sure when you create the app connect action tat the checkbox for No Auto Load is off so it loads when the page loads.

Yes this is what I do, it is a very common thing but it is not working. Maybe the issue is caused from other elements on the page. Trying on an empty page to make sure it is working. Thank you very much!

Are your $_GET vars on the page doing anything else besides the update action, I had a similar issue at some point, and had to tell my update to fire rather on success of a query that parsed the get variables, also on load.
Maybe another thing to look at and you have probably already done this but in your update have you parsed the parameters.
So this should work in theory

<dmx-serverconnect id="whatever" url="dmxConnect/api/update_action.php" dmx-param:getvarA="$_GET variable stored in the update procedure A" dmx-param:getvarB="$_GET variable stored in the update procedure B"></dmx-serverconnect>

First of all thank you for helping me put my thoughts on track. Yes after the update I am using a query to get the updated values, but even when I removed the query, update was not working. Tried on an empty page (just the update action along with the query) and it did update…so it is an issue coming from other parts of the webpage. I am investigating this :slight_smile:

Really thank you very much!!!

No problem @t11, I do try wherever possible, lol. If I did not do at least 20 moronic things in code a day I would be lost, and normally because I love talking out loud to myself people will hear me from my office, shouting “What an A**Hole, of course that will never work because you forgot about…”, so for me it is always something small and silly that causes half my issues.

Well it worked. What I actually did was to reapply the AppConnect and Jquery from the ‘Framework UI’ (I added again the js files). Since the webpage I am working is a ‘save as’ from another subpage with some minimal changes bet something was broken. Reapplying the ‘AppConnect’ & ‘Jquery’ made it work.

An interesting point is that on the debugger ‘Chrome->Network tab’ the action does not appear as executed although it does execute…

Thank you vey much @psweb

Wonder if it was the order of the .js files, I have had a nightmare with that, glad it is working though, just strange it is not showing in the debugger but still firing, its a pleasure @t11

1 Like

You should see it there - maybe you have some filters applied in the network tab. Makes sure to show all. Or jusy the XHR as server actions are actually XHR calls

1 Like

Yes I think you are right, because, now that you mentioned it, I just rememered that yesterday I did apply some filters there

Oh yes, that was it. I filtered it to show images only since I was testing something and then just forgot to clear it. Thank you

1 Like