AJAX Question

Discussion in 'Javascript' started by Joel Byrd, Jan 21, 2006.

  1. Joel Byrd

    Joel Byrd Guest

    I want a website that works in the following way: It has a main
    content div, and of course menu items. When you click a menu item, it
    should use AJAX to change the main content div to the content of the
    page of the menu item you clicked. So, for example, if you clicked
    "About Us", then in the main content div, you would see the content of
    the about us page. Now, this is pretty simple if the content of a
    given page is just text (I just get the content of the page and set the
    innerHTML property of the div to this content - I know there are
    different opinions on the Kosherness of innerHTML, but...). But the
    rub lies when the page that I want to fill the main content with
    contains more than just simple html. For example, it is a contact form
    and it contains some javascript for client-side form validation. It
    gets a little icky when I'm trying to dynamically load javascript using
    AJAX (in other words, it doesn't work - either the responseText is
    invalid or the status returned is not 200, and I know this because the
    code is not getting past the following condition: if
    (http.responseText.indexOf('invalid') == -1 && http.status == 200)...

    Are there any thoughts on using AJAX to dynamically load content on the
    fly that is more than just plain html (I guess this means at least
    javascript)? Is this just a really bad idea to begin with, are there
    decent methods of doing this, etc...
    Joel Byrd, Jan 21, 2006
    #1
    1. Advertising

  2. for center part (content part) why don't you use iframe to display
    information which contain forms and other ? just suggestion.
    --> Murali <--
    Joel Byrd wrote:
    > I want a website that works in the following way: It has a main
    > content div, and of course menu items. When you click a menu item, it
    > should use AJAX to change the main content div to the content of the
    > page of the menu item you clicked. So, for example, if you clicked
    > "About Us", then in the main content div, you would see the content of
    > the about us page. Now, this is pretty simple if the content of a
    > given page is just text (I just get the content of the page and set the
    > innerHTML property of the div to this content - I know there are
    > different opinions on the Kosherness of innerHTML, but...). But the
    > rub lies when the page that I want to fill the main content with
    > contains more than just simple html. For example, it is a contact form
    > and it contains some javascript for client-side form validation. It
    > gets a little icky when I'm trying to dynamically load javascript using
    > AJAX (in other words, it doesn't work - either the responseText is
    > invalid or the status returned is not 200, and I know this because the
    > code is not getting past the following condition: if
    > (http.responseText.indexOf('invalid') == -1 && http.status == 200)...
    >
    > Are there any thoughts on using AJAX to dynamically load content on the
    > fly that is more than just plain html (I guess this means at least
    > javascript)? Is this just a really bad idea to begin with, are there
    > decent methods of doing this, etc...
    Murali IPRLAB, Jan 21, 2006
    #2
    1. Advertising

  3. Joel Byrd wrote:

    > Are there any thoughts on using AJAX to dynamically load content on the
    > fly that is more than just plain html (I guess this means at least
    > javascript)? Is this just a really bad idea to begin with, are there
    > decent methods of doing this, etc...


    Since it sounds like you are replacing the majority of the page, you are
    effectively just reinventing frames - along with all their problems (like
    bookmarkability, search engine unfriendlyness, etc, etc) but with the bonus
    of requiring the user to have JavaScript. So, it sounds like a really bad
    idea.

    --
    David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
    Home is where the ~/.bashrc is
    David Dorward, Jan 21, 2006
    #3
  4. David Dorward wrote:
    > Joel Byrd wrote:

    <snip>
    >> ... Is this just a really bad idea to begin with, ...

    <snip>
    > Since it sounds like you are replacing the majority of the
    > page, you are effectively just reinventing frames - along
    > with all their problems (like bookmarkability, search engine
    > unfriendlyness, etc, etc) but with the bonus of requiring the
    > user to have JavaScript. So, it sounds like a really bad idea.


    The javascript dependence is not the end of the story because
    XmlHtttpRequests on IE require that ActiveX be configured to be
    scriptable in the applicable security zone. The majority of browsers may
    be IE, the majority of IE browsers may have scripting enabled, and the
    majority of script-enabled IE browsers may allow the scripting of
    ActiveX in the Internet security zone, but a majority of a majority of a
    majority may end up being a minority of the total.

    It is not really realist for a public web site to ask to be added to the
    'Trusted' security zone in order that it works at all. That request
    alone would represent reasonable grounds for suspicion on the part of
    the user.

    AJAX may be a viable strategy for the creation of web applications and
    on Intranets (where users will accept a requirement place the
    application/Intranet in the trusted security zone in order to use it)
    but its use on public web sites is extremely suspect.

    Richard.
    Richard Cornford, Jan 21, 2006
    #4
  5. Digital wrote:
    > You do not need to worry about that with IE.


    By which I assume you mean that you do not want to worry about it.

    > By default the XMLHTTP ActiveX object will work even
    > after installing SP2 for XP.


    It would be inept not to consider the possibility that use configurable
    software may be subject to user configuration.

    > You will not need to ask your users to do anything.


    Certainly I will not need to ask my users to do anything, but that will
    be a consequence of considerate design rather than burying my head in
    the sand.

    > This is because it is installed and configured as executable
    > when you install IE, unlike other ActiveX controls that the
    > user installs afterwards.


    And it takes one interaction with one checkbox to turn it off.

    > There are a few other ActiveX controls that also continue
    > working with XP after an SP2 install. I believe Flash is
    > one of them.


    And what of SP3 or 4? Microsoft's recent habit when responding to
    security concerns has been to increase the default restrictions that
    apply to various security zones, rather then fix the problems at source.

    But still, as installed is only as operated in the majority of cases,
    and the size of the minority that chooses to be more secure is not going
    to be practical to determine.


    <snip>
    >... . The only users you really need to worry about are
    > those on corporate networks that have had the XMLHTTP
    > object disabled.


    Ah, yes. The people with the big money.

    > This is very rare as the object has been heavily used in
    > the enterprise for close to 8 years by corporations offering
    > OWA to their employees. In addition many web based enterprise
    > apps have been using the webservice.htc for years now and that
    > relies on the XMLHTTP ActiveX object.


    And it is perfectly normal for web applications and Intranets to operate
    in their own security zones, so the use of XmlHttpRequests in business
    (and particularly inside businesses) has no barring on what may be
    suitable for a public Internet site.

    <snip.
    > .. . So the bottom line is that unless a user specifically
    > disables it, the XMLHTTP ActiveX object will be available
    > to you.


    So it is enabled unless it is disabled. The question is; is scriptable
    ActiveX being disabled a good reason for a public web site to be turning
    away visitors/customers (and who should be making that (theoretically
    business) decision). Plenty of web sites have been created and worked
    reliably without a dependency upon XmlHttpRequest.

    > "Richard Cornford" <Richard@...

    <snip>

    Please do not top-post to comp.lang.javascript.

    Richard.
    Richard Cornford, Jan 21, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    20
    Views:
    1,899
    d1srupt3r
    Mar 31, 2008
  2. darrel

    beginner AJAX questions (AJAX.net)

    darrel, Apr 27, 2006, in forum: ASP .Net
    Replies:
    5
    Views:
    2,438
    Flinky Wisty Pomm
    Apr 28, 2006
  3. jobs
    Replies:
    0
    Views:
    365
  4. =?Utf-8?B?QnJpYW4gRWR3YXJkcw==?=

    Deploying ASP.NET AJAX-Enabled Web site to host without AJAX insta

    =?Utf-8?B?QnJpYW4gRWR3YXJkcw==?=, Feb 20, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    592
    Patrick
    Feb 21, 2007
  5. minnie
    Replies:
    1
    Views:
    686
    Andrew Thompson
    Dec 13, 2006
Loading...

Share This Page