Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #3792

Re: Embedding HTML Within a PHP Statement

From Jerry Stuckle <jstucklex@attglobal.net>
Newsgroups comp.lang.php
Subject Re: Embedding HTML Within a PHP Statement
Date 2011-11-14 14:18 -0500
Organization A noiseless patient Spider
Message-ID <j9rphp$72v$1@dont-email.me> (permalink)
References <mhg1c7p6qe5ng95rfiguu1b0tu18143m4a@4ax.com> <timstreater-C9865F.10393114112011@news.individual.net> <4ec0f420$0$6915$e4fe514c@news2.news.xs4all.nl> <timstreater-B97A0A.12301714112011@news.individual.net> <4ec11f55$0$6973$e4fe514c@news2.news.xs4all.nl>

Show all headers | View raw


On 11/14/2011 9:01 AM, Erwin Moller wrote:
> On 11/14/2011 1:30 PM, Tim Streater wrote:
>> In article <4ec0f420$0$6915$e4fe514c@news2.news.xs4all.nl>,
>> Erwin Moller
>> <Since_humans_read_this_I_am_spammed_too_much@spamyourself.com> wrote:
>>
>>> I don't think that approach is very recommendable.
>>> At least not as a general recipe.
>
>
> Hello Tim,
>
>>
>> It won't cover many situations, I agree.
>>
>>> A few drawbacks:
>>> - Your full ajax approach results in multiple requests to the server
>>> (where one request would suffice without AJAX.).
>>
>> I would rather eat three correctly-sized meals a day than one very big
>> meal once a week.
>
> Me too.
> But your analogy doesn't explain why you think it is better.
>
> Are you stating that all-in-once versus multiple AJAX-calls is somehow
> better/easier for the server?
> Maybe lower memory-load of multiple small requests outperforms the
> higher memory load of one (bigger) request?
>
> But that is just guessing. I am curious what your rationale behind that
> statement is.
>
> Please don't respond with more food. :P
>
>
>>
>>> - It also demands the client to have Javascript enabled.
>>
>> Yes, and so what. My application has 7500 lines of PHP and 12000 or so
>> lines of javaScript. I see no prospect of being able to replace the
>> JavaScript by some clever CSS.
>
> I don't know your application of course.
> The reason I replied to your post is simply because in typical*
> situations it isn't necessarily a good approach.
>
> *By typical I mean: client/server, where:
> client=browser on some device,
> server=webserver serving HTML using PHP as language.
>
>
>>
>>> - Many searchengines and their associated crawlers don't execute
>>> Javascript, so they will be blind for that fetched content.
>>
>> While some might, and with good reason, personally I don't take the
>> needs of search engines into account.
>
> OK. Fair enough. :-)
>
>>
>>> - In many cases the back button will give unexpected results, and
>>> bookmarking a page becomes a guessing game.
>>
>> Mmm. In everything you say here, you make the mistake of assuming that
>> PHP, browser, JavaScript are components that can *only* be used in a
>> traditional browser-on-my-computer, server-somewhere-remote scenario.
>> This is an error.
>>
>
> Yes, I responded to the OP with that typical set-up in mind, since the
> OP didn't indicate anything else I saw little reason to do so.
>
> [short intermezzo at a driving school]
>
> Student: "So if I want to break I press the right pedal?"
> Driving instructor: "Correct."
>
> ...Student crashes into a wall trying to use right pedal to break...
>
> Student: "Why the $#$# did you tell me to use that right pedal?"
> Driving instructor: "Because that is where the breaks are in my 1891
> Daimler. It is a beautiful car by the way."
>
> [/short intermezzo]
>
> PS: I have no clue where the breaks actually are in a 1891 Daimler. ;-)
>
>
>>> I also fail to see why you claim "much cleaner for the user POV".
>>
>> Because reloading a page is messy and slow from the user's PoV. Instead
>> you can use AJAX to respond in a much more timely way depending what
>> they are doing. Or validate their form as they are entering it, or do
>> something like a postcode or address lookup.
>
> Yes, all the above are perfectly good examples where AJAX makes sense
> from a user POV. (I assume you validate the data again serverside.)
> I won't argue about that, and I use it myself in similar situations.
>
> But why build the better part of your document like that?
> Why fetch the main content via Ajax?
> I have seen this before, I understand how to do it, but I don't
> understand the why.
> The only valid reason I can think of is the flashing/buildup of the new
> document, but I never felt that out-weighted all the drawbacks (poor
> navigation/bookmarking are the worst).
>
>
>> And yes, in most instances
>> you can offer a degraded approach in the case where the user *has*
>> turned off JS, but then they get a poorer service and may not understand
>> why.
>
> And what about bookmarking?
> And intuitive use of the back button?
>
> Those things often feel broken to me when using AJAX-riddled websites.
>
> Regards,
> Erwin Moller
>
>

Erwin, you are correct.  Bringing everything down in one swell foop is 
much more efficient network-wise.

Assuming the data in both are identical, the same amount of data will be 
downloaded.  However, using AJAX requires multiple requests, along with 
the associated network traffic, server load and file system access than 
doing in one piece.  Additionally, if the server is using compression, 
it will almost assuredly be able to more efficiently compress one large 
block than several smaller blocks, further lowering both server load and 
network traffic.

Of course, that's not to mention the additional overhead on the client 
to interpret and process all that javascript (which, BTW, must also be 
downloaded - additional server and network traffic!).

AJAX has its uses - but using it in place of simply downloading the page 
is massive abuse, IMHO.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Embedding HTML Within a PHP Statement Call Me Tom <noemail@nowhere.com> - 2011-11-14 02:29 -0500
  Re: Embedding HTML Within a PHP Statement Erwin Moller <Since_humans_read_this_I_am_spammed_too_much@spamyourself.com> - 2011-11-14 11:10 +0100
    Re: Embedding HTML Within a PHP Statement Balazs Nadasdi <yitsushi@gmail.com> - 2011-11-14 05:07 -0800
      Re: Embedding HTML Within a PHP Statement Jerry Stuckle <jstucklex@attglobal.net> - 2011-11-14 08:19 -0500
        Re: Embedding HTML Within a PHP Statement Balazs Nadasdi <yitsushi@gmail.com> - 2011-11-14 06:41 -0800
          Re: Embedding HTML Within a PHP Statement Jerry Stuckle <jstucklex@attglobal.net> - 2011-11-14 13:59 -0500
            Re: Embedding HTML Within a PHP Statement Balazs Nadasdi <yitsushi@gmail.com> - 2011-11-14 11:41 -0800
              Re: Embedding HTML Within a PHP Statement Jerry Stuckle <jstucklex@attglobal.net> - 2011-11-14 15:22 -0500
                Re: Embedding HTML Within a PHP Statement Balazs Nadasdi <yitsushi@gmail.com> - 2011-11-14 17:44 -0800
      Re: Embedding HTML Within a PHP Statement Erwin Moller <Since_humans_read_this_I_am_spammed_too_much@spamyourself.com> - 2011-11-14 14:29 +0100
      Re: Embedding HTML Within a PHP Statement houghi <houghi@houghi.org.invalid> - 2011-11-14 20:54 +0100
        Re: Embedding HTML Within a PHP Statement Michael Fesser <netizen@gmx.de> - 2011-11-14 21:47 +0100
        Re: Embedding HTML Within a PHP Statement Ross McKay <au.org.zeta.at.rosko@invalid.invalid> - 2011-11-16 09:15 +1100
  Re: Embedding HTML Within a PHP Statement Tim Streater <timstreater@greenbee.net> - 2011-11-14 10:39 +0000
    Re: Embedding HTML Within a PHP Statement Erwin Moller <Since_humans_read_this_I_am_spammed_too_much@spamyourself.com> - 2011-11-14 11:57 +0100
      Re: Embedding HTML Within a PHP Statement The Natural Philosopher <tnp@invalid.invalid> - 2011-11-14 11:49 +0000
      Re: Embedding HTML Within a PHP Statement Tim Streater <timstreater@greenbee.net> - 2011-11-14 12:30 +0000
        Re: Embedding HTML Within a PHP Statement Erwin Moller <Since_humans_read_this_I_am_spammed_too_much@spamyourself.com> - 2011-11-14 15:01 +0100
          Re: Embedding HTML Within a PHP Statement Tim Streater <timstreater@greenbee.net> - 2011-11-14 14:39 +0000
            Re: Embedding HTML Within a PHP Statement Michael Fesser <netizen@gmx.de> - 2011-11-14 18:07 +0100
            Re: Embedding HTML Within a PHP Statement Gregor Kofler <usenet@gregorkofler.com> - 2011-11-15 23:55 +0100
              Re: Embedding HTML Within a PHP Statement Tim Streater <timstreater@greenbee.net> - 2011-11-15 23:02 +0000
                Re: Embedding HTML Within a PHP Statement Gregor Kofler <usenet@gregorkofler.com> - 2011-11-16 00:06 +0100
                Re: Embedding HTML Within a PHP Statement Tim Streater <timstreater@greenbee.net> - 2011-11-16 10:10 +0000
                Re: Embedding HTML Within a PHP Statement Denis McMahon <denismfmcmahon@gmail.com> - 2011-11-16 14:23 +0000
          Re: Embedding HTML Within a PHP Statement Jerry Stuckle <jstucklex@attglobal.net> - 2011-11-14 14:18 -0500
        Re: Embedding HTML Within a PHP Statement Denis McMahon <denismfmcmahon@gmail.com> - 2011-11-14 18:52 +0000
  Re: Embedding HTML Within a PHP Statement Arno Welzel <usenet@arnowelzel.de> - 2011-11-14 13:39 +0100
  Re: Embedding HTML Within a PHP Statement Gregor Kofler <usenet@gregorkofler.com> - 2011-11-14 13:54 +0100
  Re: Embedding HTML Within a PHP Statement Denis McMahon <denismfmcmahon@gmail.com> - 2011-11-14 13:54 +0000
  Re: Embedding HTML Within a PHP Statement bobm3@worthless.info - 2011-11-14 21:15 -0500

csiph-web