0

Is there anyone who can tell me how to do this? This is the call I use here for loading content dynamically:

jQuery(document).ready(function($) {
    function load(num) {
        $('#pageContent').load(num +".html");
    }

    $.history.init(function(url) {
            load(url == "" ? "1" : url);
        });

    $('#bbon a').live('click', function(e) {
            var url = $(this).attr('href');
            url = url.replace(/^.*#/, '');
            $.history.load(url);
            return false;
        });
});

It uses jQuery to initiate the history plugin. Can this be modified to somehow use the hashbang? I've read a lot of articles but nothing gives you an example of how to do this.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
Ricki
  • 933
  • 2
  • 15
  • 33
  • 1
    Hey Ricki, I just included your code into the question so that it is easier for people to see what it is about and won't go away if you delete the file from your server. I hope that's okay with you. – middus Mar 13 '11 at 00:54
  • By hashbang do you mean hash? What do you mean by "use the hashbang?" What is your code doing and what do you want it to do? – Explosion Pills Mar 13 '11 at 04:13
  • see below comments in the answer – Ricki Mar 13 '11 at 09:43

2 Answers2

1

Have a look at this example for hashbang http://www.amitpatil.me/create-gmail-like-app-using-html5-history-api-and-hashbang/

www.amitpatil.me
  • 3,001
  • 5
  • 43
  • 61
0

The original version of the question asked about 'hashbang/shebang'.

What is a shebang

On Unix-like systems, a script (file) starts with a shebang if it starts with the characters '#' (hash) and '!' (bang):

#!/usr/bin/env perl

(for example), then the kernel knows to run the program /usr/bin/env with the argument perl, thus running the Perl interpreter on the script that is specified on the command line. So, if that was the first line of a file xyz.pl, then Perl will be given xyz.pl as its standard input.

This only works, AFAIK, when a program/script is executed.

I don't know enough about how you might be running Javascript or JQuery, but if it was going to work, you'd have to be able to put something like this at the top of a file (which would also need execute (and read) permssion on the file):

#!/usr/bin/js

...Javascript to be executed/interpreted

However, this question seems to be about marks within Ajax code, and the term shebang probably shouldn't be used for this.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
  • 1
    I think he is asking about using the hash (possibly with an exclamation point). js cannot be run from the command line and has no linux builtin that I know of, so there is no `/usr/bin/js` – Explosion Pills Mar 13 '11 at 04:12
  • @tandu: I'm not surprised to hear that the shebang I described doesn't apply to Javascript (at least, in the form I described it). But then the question may simply be inaccurately asked. – Jonathan Leffler Mar 13 '11 at 04:57
  • it probably is inaccurately asked, but yes, the exclamation mark after the hashtag, this is what i want to use in my site. Eg. Mywebsite.com/#!apage so google can correctly index my ajax content – Ricki Mar 13 '11 at 09:42
  • i noticed you answered this question: stackoverflow.com/questions/4964173/general-questions-about-hashbang-urls-and-am-i-using-them-correctly. This is subsequently what i wanted to know. I dont completely know what u mean, can we continue this in email? – Ricki Mar 13 '11 at 19:48
  • @Ricki: I don't think I answered that question - I don't have the knowledge to do so. – Jonathan Leffler Mar 13 '11 at 21:47