File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes JQuery multiple GET request URL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "JQuery multiple GET request URL" Watch "JQuery multiple GET request URL" New topic
Author

JQuery multiple GET request URL

Md Uddin
Ranch Hand

Joined: Jan 11, 2006
Posts: 30
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.


MURAD (SCJP 5.0, SCWCD 1.4)
If you learn to program in Java, you'll never be without a job! (Patricia Seybold in 1998) - Knowing the syntax of Java does not make someone a software engineer. (John Knight)
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Make the url a variable and set the variable?

Eric
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60774
    
  65

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


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Md Uddin
Ranch Hand

Joined: Jan 11, 2006
Posts: 30
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
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
You want to send 4 requests at one time?

Eric
Md Uddin
Ranch Hand

Joined: Jan 11, 2006
Posts: 30
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
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
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

Joined: Jan 11, 2006
Posts: 30
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
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60774
    
  65

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

Joined: Jan 11, 2006
Posts: 30
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
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60774
    
  65

Look at the methods under Ajax Events.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JQuery multiple GET request URL
 
Similar Threads
jQuery.ajax() issue with chrome and IE 8
Ajax with jQuery and servlets
Removing brackets from arraylist printout.
POST parameters don't appear in a PHP page
Falling in love with jQuery?