Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript AJAX problem

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #31674
    asp
    Participant

    Hei

    I’m making a AJAX script for å wordpress theme. I have got the basic .load function to fork, but i am having som problems hven the link is set ti .click. Som how the script only works when it’s set to .hover. This is the links to display next post hven your in one. I hope somone can help.

    //ajaxing post

    $(function() {
    var $article = $("#article"),
    $eldre = $(".older a"),
    $siteURL = "http://" + top.location.host.toString(),
    $URL = '',
    $el;

    $eldre.hover(function(e){

    $el = $(this);

    URL = $el.attr("href");
    URL = URL + " #article";

    $article.load(URL);

    });
    });

    $(function() {
    var $article = $("#article"),
    $nyere = $(".newer a"),
    $siteURL = "http://" + top.location.host.toString(),
    $URL = '',
    $el;

    $nyere.click(function(){

    $el = $(this);

    URL = $el.attr("href");
    URL = URL + " #article";

    $article.load(URL);

    });
    });

    This is the code. I tryed to follow Chris’ screancast on AJAXing a wordpress theme.

    Hope somone can help.

    #59176
    asp
    Participant

    Well, I figured it out.

    And here is the result:


    //ajaxing post

    $(function() {
    var $article = $("#article"),
    $eldre = $(".eldre"),
    $siteURL = "http://" + top.location.host.toString(),
    $URL = '',
    newHash = "",
    $el;

    $eldre.click(function(){

    window.location = $(this).attr("href");

    newHash = window.location.substring(23);

    URL = $el.attr("href");
    URL = URL + " #article";

    $article.load(URL);

    console.log(newHash);

    });
    });

    $(function() {
    var $article = $("#article"),
    $nyere = $(".nyere"),
    $siteURL = "http://" + top.location.host.toString(),
    $URL = '',
    $el;

    $nyere.click (function(){

    window.location = $(this).attr("href");

    newHash = window.location.substring(23);

    URL = $el.attr("href");
    URL = URL + " #article";

    $article.load(URL);

    console.log(newHash);

    });
    });

    Its a really nice. I use it to flipp trough articles on my blog.

    You are free to use it.

    But if you know hov to add a transition effect, let me know ;)

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.