Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9013795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:21:24+00:00 2026-06-16T03:21:24+00:00

I have this list of things generated from an array, where the array value

  • 0

I have this list of things generated from an array, where the array value maps to the array key, which maps to a query in the database. Now the problem I’m facing is that when this list is included in my ajax portion, it only works for one click before the page refreshes. What gives?

I’m using the HTML5 History API method to change the url upon clicks by the href=”” portion of the link.
I’m somewhat new to jQuery, which is odd since I’m a front end developer primarily but I just never got the time to catch up, but my link list breaking this code just doesn’t make sense to me.

$("a[rel='ajax']").click(function(e){
    //e.preventDefault();

    pageurl = $(this).attr('href');

    $.ajax({url:pageurl+'?rel=ajax',success: function(data){
        $('#ajax')
        .load(pageurl + ' #resultati');
    }});


    if(pageurl!=window.location){
        window.history.pushState({path:pageurl},'',pageurl);
    }
    return false;
});

The links are generated using this function in PHP, I’m using the laravel framework if that makes any difference.

public static function filterlink ($filter, $what)
{
    if (URI::segment(2) == 'make')
    {
        $first = URI::segment(3);
        $next = URI::segment(4);
    }
    else
    {
        $first = URI::segment(2);
        $next = URI::segment(3);
    }

    // what == 0 is the filter, what == 1 is the +filter. This reffers to the link being created.
    switch (substr($first, 0, 1))
    {
        case ' ': // example.ex/make/[+]current starts with a plus sign.
            if($what == 0)
                //new no+ filter.
            {
                return HTML::link('make/'.self::slug($filter.'/'.$first), $filter, array('rel' => 'ajax')); 
                // example.ex/make/+current => example.ex/make/newfilter/+current 
            } 
            elseif($what == 1) 
                //new +filter
            {
                return HTML::link('make/+'.self::slug($filter), $filter, array('rel' => 'ajax')); 
                // example.ex/make/+current+replaced+by+newfilter
            }
        break;


        default: 
            if($what == 0) 
            // new no+ filter.
            {
                if(!empty($next))
                {
                    return HTML::link('make/'.self::slug($filter.'/'.$next), $filter, array('rel' => 'ajax'));
                }
                else
                {
                    return HTML::link('make/'.self::slug($filter), $filter, array('rel' => 'ajax'));
                }
            }
            elseif($what == 1 && (!empty($first)))
            {
                return HTML::link('make/'.self::slug($first.'/+'.$filter), $filter, array('rel' => 'ajax'));
            }
            elseif($what == 1 && (empty($first)))
            {
                return HTML::link('make/+'.self::slug($filter), $filter, array('rel' => 'ajax'));
            }

        }
    }

I’ve tried putting my link lists outside the ajax field, which keeps the ajax flow going without any boring page refreshes, but my link urls don’t update, obviously, and I’m only able to construct one-ended links, breaking the pages dual filter functionality.

Any help would be great.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T03:21:26+00:00Added an answer on June 16, 2026 at 3:21 am

    If you’re actually loading HTML content with links that you want to be AJAX friendly, then you’ll need to use .on so that the new links also get taken over by your jQuery function.

    $(document).on('click',"a[rel='ajax']",function(e) {
    

    Working sample here:

    http://jsfiddle.net/hansvedo/cJW54/


    Just a quick thought, what about placing preventDefault where the pushState function is? Or even just uncommenting it where it is? preventDefault prevents the normal linking action from happening.

    if(pageurl!=window.location){
        e.preventDefault();
        window.history.pushState({path:pageurl},'',pageurl);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an issue concerning constraints which should be generated dynamically from a list
So i have this output generated from a jQuery function i built (ajax) which
I have an array in c# that is 1-based (generated from a call to
I have an APK generated from eclipse which contains a native library packaged inside
At page index.htm, I have this list: <ul id=topic> <li id=1>Thing1.</li> <li id=2>Thing2.</li> </ul>
I have this list of people with checkboxes next to their names. When you
We Have this : List<Person> listPerson ; Want to use the Data of listPerson
I have this list: mylist = [20, 30, 25, 20, 30] After getting the
I have this List<string> . How to get certain strings via LINQ? I guessed
If I have this list with 10 elements: >>> l = [1,2,3,4,5,6,7,8,9,0] Why will

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.