[RFC|Merged] AJAX

These requests for comments/change have lead to an implemented feature that has been successfully merged into the 3.1/Ascraeus branch. Everything listed in this forum will be available in phpBB 3.1.
Post Reply
User avatar
callumacrae
Infrastructure Team
Infrastructure Team
Posts: 1046
Joined: Tue Apr 27, 2010 9:37 am
Location: England
Contact:

[RFC|Merged] AJAX

Post by callumacrae » Wed Jul 13, 2011 8:37 pm

Some operations currently require several page loads where it really isn't necessary. I propose to make quite a lot of these operations use AJAX.

This would have a few advantages. One is that it would obviously reduce the number of pages that the user would have to load, meaning that it would be faster for them, both in page loading and rendering time. It would also reduce HTTP requests (assuming that the browser isn't caching everything)

If implimented correctly, this will have no drawbacks at all. Existing code that uses, for example, confirm_box will still function correctly, and it would be easy for them to change to AJAX if they chose, taking advantage of thIs system. It would function correctly in browsers with JavaScript disabled, as implimenting this would not involve removing any code and so they could use the existing mechanisms.


The following operations should use AJAX:
  • Pretty much everything that uses confirm_box - deleting posts, moderator options, etc. [ticket] merged
  • Everything that displays a message and then redirects, such as subscribing to a topic [ticket] merged
  • Approving and denying posts [ticket] merged
  • Changing settings in the UCP and MCP [denied]
  • Editing posts - RFC
  • Reordering forums in the ACP [ticket] merged
  • Quick reply [ticket]

That's all I can think of at the moment. I can't imagine getting all of these done in the neat future, although I'm certainly going to try. Anyone got any other ideas / comments?
Last edited by callumacrae on Sat Mar 31, 2012 12:40 pm, edited 7 times in total.
Made by developers, for developers!
My blog

User avatar
DavidIQ
Customisations Team Leader
Customisations Team Leader
Posts: 1731
Joined: Thu Mar 02, 2006 4:29 pm
Location: Earth
Contact:

Re: [RFC] AJAX

Post by DavidIQ » Wed Jul 13, 2011 10:04 pm

Although I like the idea of having AJAX and eliminating the visual of page posts some of the ones you listed could just be done with some simple JavaScript confirm boxes or a modal of some sort and don't really require a whole page post (AJAX) to take care of. The confirm_box ones would be perfect candidates for that and you would end up not having to load/reload anything.

I think AJAX could be better used for more complex operations such as deleting or editing a post inline, subscribing to forums/posts, previewing posts, etc.
Image

User avatar
callumacrae
Infrastructure Team
Infrastructure Team
Posts: 1046
Joined: Tue Apr 27, 2010 9:37 am
Location: England
Contact:

Re: [RFC] AJAX

Post by callumacrae » Wed Jul 13, 2011 11:06 pm

DavidIQ wrote:Although I like the idea of having AJAX and eliminating the visual of page posts some of the ones you listed could just be done with some simple JavaScript confirm boxes or a modal of some sort and don't really require a whole page post (AJAX) to take care of. The confirm_box ones would be perfect candidates for that and you would end up not having to load/reload anything.

I think AJAX could be better used for more complex operations such as deleting or editing a post inline, subscribing to forums/posts, previewing posts, etc.
confirm_box also serves the purpose of stopping CSRFs :-)

Marked stuff as read / subscribing to stuff is a good idea, I hadn't thought of that.
Made by developers, for developers!
My blog

User avatar
Meis2M
Registered User
Posts: 411
Joined: Fri Apr 23, 2010 10:18 am
Contact:

Re: [RFC] AJAX

Post by Meis2M » Thu Jul 14, 2011 3:41 am

good idea.
i think this RFC can come in 3.1 too

User avatar
/a3
Registered User
Posts: 97
Joined: Mon Sep 20, 2010 6:44 am

Re: [RFC] AJAX

Post by /a3 » Thu Jul 14, 2011 7:23 am

For pages which aren't indexed by search engines, I believe this would be generally OK. The only problem would be if someone linked to such a page (assuming we're using hashbangs?) and the person visiting the page didn't have JavaScript. However, since it's for things like the ACP/UCP, the chance of someone actually manually linking would be fairly small.

I'd just like to say that there, of course, must be a non-JavaScript alternative!
$ git commit -m "YOLO"

User avatar
callumacrae
Infrastructure Team
Infrastructure Team
Posts: 1046
Joined: Tue Apr 27, 2010 9:37 am
Location: England
Contact:

Re: [RFC] AJAX

Post by callumacrae » Thu Jul 14, 2011 7:32 am

I think that most of these will be in 3.1, but I can't make RFCs in that forum.
/a3 wrote:For pages which aren't indexed by search engines, I believe this would be generally OK. The only problem would be if someone linked to such a page (assuming we're using hashbangs?) and the person visiting the page didn't have JavaScript. However, since it's for things like the ACP/UCP, the chance of someone actually manually linking would be fairly small.

I'd just like to say that there, of course, must be a non-JavaScript alternative!
Why would anyone link to "You have successfully posted a thread" or "Are you sure you want to delete this?"? We're not using hashbangs because we're not loading entire pages, just confirmation boxes and stuff.

There will be a fallback - this won't involve editing any existing code, just dropping in new code. I've already converted a couple of the confirm_boxes to AJAX, I'll push them to GH later.

~Callum
Made by developers, for developers!
My blog

User avatar
/a3
Registered User
Posts: 97
Joined: Mon Sep 20, 2010 6:44 am

Re: [RFC] AJAX

Post by /a3 » Thu Jul 14, 2011 8:22 am

OK, I see. I misunderstood what exactly you wished to use AJAX for.
$ git commit -m "YOLO"

User avatar
callumacrae
Infrastructure Team
Infrastructure Team
Posts: 1046
Joined: Tue Apr 27, 2010 9:37 am
Location: England
Contact:

Re: [RFC] AJAX

Post by callumacrae » Thu Jul 14, 2011 2:54 pm

https://github.com/callumacrae/phpbb3/c ... ure%2Fajax is everything I have done so far, if anyone is interested
Last edited by callumacrae on Thu Jul 28, 2011 10:59 am, edited 1 time in total.
Made by developers, for developers!
My blog

User avatar
DavidIQ
Customisations Team Leader
Customisations Team Leader
Posts: 1731
Joined: Thu Mar 02, 2006 4:29 pm
Location: Earth
Contact:

Re: [RFC] AJAX

Post by DavidIQ » Thu Jul 14, 2011 3:12 pm

callumacrae wrote:confirm_box also serves the purpose of stopping CSRFs :-)
Yes and you can still prevent that using simple javascript confirm boxes. Not sure what you're doing additionally using AJAX but whatever you're doing through AJAX can be done at the eventual post action after the user clicks on OK. You're really just masking the post and not saving the server any load.
Image

User avatar
callumacrae
Infrastructure Team
Infrastructure Team
Posts: 1046
Joined: Tue Apr 27, 2010 9:37 am
Location: England
Contact:

Re: [RFC] AJAX

Post by callumacrae » Thu Jul 14, 2011 3:40 pm

DavidIQ wrote:
callumacrae wrote:confirm_box also serves the purpose of stopping CSRFs :-)
Yes and you can still prevent that using simple javascript confirm boxes. Not sure what you're doing additionally using AJAX but whatever you're doing through AJAX can be done at the eventual post action after the user clicks on OK. You're really just masking the post and not saving the server any load.
The point is that there has to be two requests to prevent CSRFs - one to get a confirmation code (which is then saved in the database), and then second to send the confirmation code back to the server. Simply displaying "Are you sure?" in JS isn't good enough, it has to involve a code from the server.
Made by developers, for developers!
My blog

Post Reply