Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialRodrigo Muñoz
Courses Plus Student 20,171 PointsGenerating N urls to make AJAX requests
I'm facing a big problem after creating the API of a backend. I have a form with a GET AJAX method to filter and get results. It works fine but as the urls are generated from the users choice, there are N options I can't create each combination for when using or not each filter field.
Here is an example of one generated url:
http://example.com/api/?select1=choice1&tag=word&active=true
Also if the user decides to chose only select1
and tag
Is there a way to do this?
1 Answer
Rodrigo Muñoz
Courses Plus Student 20,171 PointsI have solved this use the jQuery property .serialize()
Christopher Misa
6,467 PointsChristopher Misa
6,467 PointsI'm not sure I completely understand your question but I have a couple Ideas:
—You could include a value like 'unknown' for fields not specified by the user then ignore these fields on the backend.
—You could include a new field which tells the backend which fields the users has specified.