PHP + JS + CSS: why ajax doesn't display using CSS on main doc?

Discussion in 'Javascript' started by SeanInSeattle, Dec 13, 2007.

  1. So, I've got a blog showing posts using AJAX, and paginated also using
    AJAX.

    My question is this: why would the posts not show up using the post-
    specific CSS if the styles are declared within an external sheet
    (post.css) which is included within the header of "listing-
    dynamic.php"? If the blog div innerHTML changes, shouldn't it still
    be showing underneath the main documents included style sheets?
    SeanInSeattle, Dec 13, 2007
    #1
    1. Advertising

  2. Re: PHP + JS + CSS: why ajax doesn't display using CSS on main doc?

    On Dec 12, 7:55 pm, SeanInSeattle <> wrote:
    > So, I've got a blog showing posts using AJAX, and paginated also using
    > AJAX.
    >
    > My question is this: why would the posts not show up using the post-
    > specific CSS if the styles are declared within an external sheet
    > (post.css) which is included within the header of "listing-
    > dynamic.php"? If the blog div innerHTML changes, shouldn't it still
    > be showing underneath the main documents included style sheets?


    Yes, when a particular blog post is retrieved using Ajax and inserted
    into the main page, the CSS style sheet in the main page will apply to
    that newly inserted bit of HTML. At least if everything is set up
    correctly and the CSS selectors are correct.

    Peter
    Peter Michaux, Dec 13, 2007
    #2
    1. Advertising

  3. Re: PHP + JS + CSS: why ajax doesn't display using CSS on main doc?

    On Dec 12, 8:44 pm, Peter Michaux <> wrote:
    > On Dec 12, 7:55 pm, SeanInSeattle <> wrote:
    >
    > > So, I've got a blog showing posts using AJAX, and paginated also using
    > > AJAX.

    >
    > > My question is this: why would the posts not show up using the post-
    > > specific CSS if the styles are declared within an external sheet
    > > (post.css) which is included within the header of "listing-
    > > dynamic.php"? If the blog div innerHTML changes, shouldn't it still
    > > be showing underneath the main documents included style sheets?

    >
    > Yes, when a particular blog post is retrieved using Ajax and inserted
    > into the main page, the CSS style sheet in the main page will apply to
    > that newly inserted bit of HTML. At least if everything is set up
    > correctly and the CSS selectors are correct.
    >
    > Peter


    The reason why I posted is because what I've been doing *isn't*
    working. I used "document.getElementById.(div_element_id).innerHTML =
    response_txt" to insert the posts, but should I have used something
    else?
    SeanInSeattle, Dec 13, 2007
    #3
  4. Re: PHP + JS + CSS: why ajax doesn't display using CSS on main doc?

    On Dec 13, 3:45 am, SeanInSeattle <> wrote:
    > On Dec 12, 8:44 pm, Peter Michaux <> wrote:
    >
    >
    >
    > > On Dec 12, 7:55 pm, SeanInSeattle <> wrote:

    >
    > > > So, I've got a blog showing posts using AJAX, and paginated also using
    > > > AJAX.

    >
    > > > My question is this: why would the posts not show up using the post-
    > > > specific CSS if the styles are declared within an external sheet
    > > > (post.css) which is included within the header of "listing-
    > > > dynamic.php"? If the blog div innerHTML changes, shouldn't it still
    > > > be showing underneath the main documents included style sheets?

    >
    > > Yes, when a particular blog post is retrieved using Ajax and inserted
    > > into the main page, the CSS style sheet in the main page will apply to
    > > that newly inserted bit of HTML. At least if everything is set up
    > > correctly and the CSS selectors are correct.

    >
    > > Peter

    >
    > The reason why I posted is because what I've been doing *isn't*
    > working. I used "document.getElementById.(div_element_id).innerHTML =
    > response_txt" to insert the posts, but should I have used something
    > else?


    Also, in my css, I'm using a classes to apply styles to the posts.
    When inserting the posts, I'm also inserting new div's around each
    post with class="post", but when they display they're not showing up
    with the styles that were included on the main document level.
    SeanInSeattle, Dec 13, 2007
    #4
  5. Re: PHP + JS + CSS: why ajax doesn't display using CSS on main doc?

    On Dec 13, 11:45 am, SeanInSeattle <> wrote:

    > The reason why I posted is because what I've been doing *isn't*
    > working.


    Well, it should.

    Is the document valid?
    If you inspect the DOM after performing the operation, does the markup
    look as you expect?
    If you construct the same DOM manually, does it act as you expect?
    What browsers exhibit this problem?
    What is the URL so we can see exactly what you are doing?

    --
    David Dorward
    http://dorward.me.uk/
    http://blog.dorward.me.uk/
    David Dorward, Dec 13, 2007
    #5
  6. Re: PHP + JS + CSS: why ajax doesn't display using CSS on main doc?

    On Dec 13, 3:58 am, David Dorward <> wrote:
    > On Dec 13, 11:45 am, SeanInSeattle <> wrote:
    >
    > > The reason why I posted is because what I've been doing *isn't*
    > > working.

    >
    > Well, it should.
    >
    > Is the document valid?
    > If you inspect the DOM after performing the operation, does the markup
    > look as you expect?
    > If you construct the same DOM manually, does it act as you expect?
    > What browsers exhibit this problem?
    > What is the URL so we can see exactly what you are doing?
    >
    > --
    > David Dorwardhttp://dorward.me.uk/http://blog.dorward.me.uk/


    LOL... um yeah. I'm a dumb ass. I said, include "post" instead of
    including "post.css". Basically, it didn't apply the post css because
    I didn't include the full filename. Sorry folks, just a typo.
    SeanInSeattle, Dec 13, 2007
    #6
    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. Matt
    Replies:
    3
    Views:
    471
    Tor Iver Wilhelmsen
    Sep 17, 2004
  2. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    838
    Mark Rae
    Dec 21, 2006
  3. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,670
    Smokey Grindel
    Dec 2, 2006
  4. Rajive Narain
    Replies:
    0
    Views:
    1,472
    Rajive Narain
    Sep 18, 2009
  5. News123
    Replies:
    0
    Views:
    277
    News123
    Feb 6, 2010
Loading...

Share This Page