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 8135415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:24:45+00:00 2026-06-06T10:24:45+00:00

So I’m using an ajax request to pass some data for filtering purposes. Then

  • 0

So I’m using an ajax request to pass some data for filtering purposes.

Then I use history.js so I can change the url and add a state to the browser, making it possible to go back, go forward etc. This way, I can filter my data with an ajax request or a normal request. So far so good.

My problem is, in the data I pass through the ajax request there is an array:

function updateContent(url, state) {
    $.ajax({
        type: 'GET',
        data: {name: state.filter_name, num: state.filter_number, 
            data: state.filter_data, array: state.filter_array},
        url: url,
        success: function(msg) {
                $('#ajax').html(msg);
        }
    }); 
    
}

This will make a request to this URL:

http: //localhost/Project/Controller/?filter_array%5B%5D=1&filter_array%5B%5D=50&filter_array%5B%5D=70.

And I want to pass this url to the history.pushstate

If I use jsenconde then build manually the url, the url will be slighter different, will be something like:

http://localhost/Project/Controller/?filter_array=["1","50","70"]

Although it’s more cleaner, I read somewhere that you shouldn’t use [] in url’s but even if I use this way I will get two types of GET url’s, the ajax URL ?filter_array%5B%5D=1&filter_array%5B%5D=50&filter_array%5B%5D=70. and the json url ?filter_array=["1","50","70"].

So I just need a solution that get’s me just one type of GET url, so I can use the same url to ajax, and normal requests.

  • 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-06T10:24:47+00:00Added an answer on June 6, 2026 at 10:24 am

    The standard way to pass an array of values is to pass the name with []‘s repeatedly (url-encoded) as in your first example.

    You need to generate your URL in such a way that it complies with this…

    filter_array[]=1&filter_array[]=2&filter_array[]=3
    

    which, of course, encodes as you showed….

    filter_array%5B%5D=1&filter_array%5B%5D=2&filter_array%5B%5D=3
    

    If you stick with this format, your code will be more portable (eg ASP.Net will perform the conversion to List automatically as will many PHP libraries).

    Is there any reason you can’t generate the url in this format?

    The difference here is that one is using standard forms encoding, the other is converting JSON

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have some data like this: 1 2 3 4 5 9 2 6
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function

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.