• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JQuery multiple GET request URL

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Consider the below JQuery example to initiates the GET request to the server:



here test.php is the URL where the request is going. Is there a good way to assign it for Multiple URL ?

Like, if I have 4 different URL (number of URL is not fixed) to send the request to ... what should I do?

Any help will be appreciated. Thank you.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Make the url a variable and set the variable?

Eric
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That greatly depends on what determines which url is to be used and when. You haven't said. How can we guess?
 
Md Uddin
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:That greatly depends on what determines which url is to be used and when. You haven't said. How can we guess?



Sorry If I couldn't make my question clear. I am very new to JQuery.

I am trying to send multiple num of request to the server and get the response back. I need to do it from one Javascript code/file.

For example, I may have 4 urls to send the request to (does not matter when, as long as all the request sent) from one Javascript file with the JQuery code.

Is that possible ?

Thank you in advance.
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You want to send 4 requests at one time?

Eric
 
Md Uddin
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Eric Pascarello wrote:You want to send 4 requests at one time?

Eric



Is it possible to send 4 request at one time ?

Let me give some more details:

Suppose I have the following 4 URLs to send the request to:

1) http:/www.testURL1.com/someThing
2) http:/www.abc123.com/anyThing?param=test
3) http:/www.testxyz.com/Logout
4) http:/www.mySite.com/Login

Now, I would like to send the request to the above URL using JQuery code (but it need to be done from one single HTML file or Java Script).
(it may be not with the .get() function ... that was my initial guess)

Thank you.
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well you are not going to be making Ajax calls to another domain from your website.

You will have to make separate calls for each URL. You can easily code one function that has the JQuery code in it with a variable for the url.

Eric
 
Md Uddin
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Eric Pascarello wrote:Well you are not going to be making Ajax calls to another domain from your website.

You will have to make separate calls for each URL. You can easily code one function that has the JQuery code in it with a variable for the url.

Eric



Hello Eric, thank you for your reply.

That is fine (as you mentioned above). But I also have to wait till I get all the responses back

another questions is:
How do I capture all the responses in one variable (or one place) ?

[a sample code will be great for whole thing ... ]


Thank you in advance.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
jQuery allows you to create "global" handling function that will be invoked at a number of staged of an Ajax request. It's a fine mechanism for consolidating processing in one place.
 
Md Uddin
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:jQuery allows you to create "global" handling function that will be invoked at a number of staged of an Ajax request. It's a fine mechanism for consolidating processing in one place.



Could you please give me an example (May be something related to my problem) ?

Thank you.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look at the methods under Ajax Events.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic