0

First of all, i am new to jQuery. I found that my web application face a problem in which a user is unable to navigate back to the previous page or even refresh the page. It's making it re-direct to the first page of the web app.
Here's part of my script

$(function() {
$("#register").click(function(evt) {
    $("#pages").load("register.php")
    evt.preventDefault();
})
})

Basically, when user click on the <li>, the page will load another content from another page.

<li><a id="register" href="">register</a></li>

I know that jQuery BBQ could solve it, but I don't know how to use it. Can anyone give me some hint?

James Allardice
  • 156,021
  • 21
  • 318
  • 304
dejiar
  • 1
  • I think the div "#pages" is the one that contains all the page right? You won't be able to go previous page because you are in the same page that your new page is loading and everything is in DOM. Also, when refreshing page, your browser thinks is the same page so the content in the div "#pages" comes as first time. Why you want BBQ? Am I correct? – Oscar Jara May 20 '12 at 18:13
  • ya..u r rite...everything was in the pages...as i nid a bbq..because i nid to allow my user to use the back button. and also if i go to my form..in that case..a server script validation fail...it will return to my first page..and not my form... any idea to do tat? i don mind to change my code as now still beginning of developing/// – dejiar May 20 '12 at 18:32

1 Answers1

1

Well, according to your comment, I think you want to use BBQ to change pages and avoid the problem of refreshing and going back to pages with jQuery load.

I made you an example.

Download link:

http://dl.dropbox.com/u/15208254/stackoverflow/jquery-bbq-example.zip

Please, run it in your localhost, because it has 2 PHP files.

Hope this helps :-)

Oscar Jara
  • 13,479
  • 10
  • 58
  • 90
  • hi, thx for the content, i will test it now and return you the result :) – dejiar May 21 '12 at 04:50
  • @dejiar sure, just let me know – Oscar Jara May 21 '12 at 04:52
  • isit necessary to use `` tag on every page? since if i no use it, the code cnt navigate correctly – dejiar May 21 '12 at 06:20
  • Its better to use it because if someone wants to navigate your url directly from the browser, what title will appear for the page? Also, when using html, you need to follow the correct syntax or html structure. – Oscar Jara May 21 '12 at 07:04
  • ok...thx for the information...I think my problem solved after 2 days of research.. THX! – dejiar May 21 '12 at 13:40
  • @dejiar Nice to help you. Please, don't forget to click on the "check" next to my answer if you think is the correct one. I am telling you this because you are new here :-) – Oscar Jara May 21 '12 at 14:51