Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How can i pass value to multiple url using ajax?  RSS feed

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


i want to send same data to day.jsp page. how can i do that?
 
Author and ninkuma
Marshal
Posts: 66684
167
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'd need to send another Ajax request.

 
robin Morshed
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am using three dowpdown menu and each of them changing based on each other. as example if i chose year then month dropdown need to be populated from database and when i chose month then day dropdown need to be populated from database based on year and month selected.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66684
167
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, I see you are using the JSP to format an HTML fragment for insertion. This should most likely be a GET rather than a POST -- is there any processing that takes place on the server besides formatting the fragment?

In any case, you cannot cause a single Ajax request to fork into two separate requests.

If the requests are very similar, you can write a function that makes the request, passing parameters that specify the differences.
 
Bartender
Posts: 19458
88
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
AJAX (Asynchronous JAvascript eXecution) is simply an ordinary HTTP request made by JavaScript. Therefore it follows the same rules as a regular HTTP request/response operation. To retrieve data from multiple URLs, you'd need to make multiple AJAX requests, since HTTP can only make a single request to a single URL per request/response cycle.

For a calendar, I suspect you're asking the wrong question. What you really want, I think, is the parts of a date, and the simplest way to do that is usually with a single URL that returns multiple items of data. That can be done in a JavaScript-friendly way by formatting the returned data in in JSON (Javascript Object Notation).

You can write a JSP page that returns JSON instead of HTML. All that's really different is that the Content-Type header for a JSON request should be "application/json" instead of "text/html".
 
You're not going crazy. You're going sane in a crazy word. Find comfort in this tiny ad:
free 1 hour java lesson
https://coderanch.com/t/695988/free-hour-java-lesson
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!