Ticket #1224 (closed feature: wontfix)

Opened 6 years ago

Last modified 5 years ago

loadURL does not support synchronous requests

Reported by: rdewit Owned by:
Priority: minor Milestone: 2.6 Release
Component: general Version: SVN
Keywords: Cc:
State:

Description

Since our Ajax class supports supports synchronous requests, it seems logical that loadURL should support that too. This patch provides that support. Since the list of parameters that are fed to the method are getting quite long, would it be an option to provide an {options} object?

P.S. Component 'Ajax' seems to be missing in the list (trac).

Attachments

patch_ajax_synchronous_loadurl.diff Download (2.6 KB) - added by rdewit 6 years ago.

Change History

follow-up: ↓ 2   Changed 6 years ago by crschmidt

In general, loadURL is designed to be the minimal wrapper around Ajax.Request. If we add more options to it, we're just making it the same as Ajax.Request. Why not just use Ajax.Request?

Changed 6 years ago by rdewit

in reply to: ↑ 1   Changed 6 years ago by rdewit

Replying to crschmidt:

In general, loadURL is designed to be the minimal wrapper around Ajax.Request. If we add more options to it, we're just making it the same as Ajax.Request. Why not just use Ajax.Request?

For advanced parsing of KML we will need to retrieve external URLs and will have to do that synchronised.

  Changed 6 years ago by crschmidt

Right. So why aren't you using Ajax.Request?

(There is a right answer here, and if you get it, then we can open a ticket for addressing it. :))

  Changed 6 years ago by crschmidt

(Btw, my previous comment isn't a test: I want to find out if the problem you're running into is the same one that I'm thinking of: if it isn't, then this ticket may have some value that I'm not seeing.)

  Changed 6 years ago by crschmidt

  • summary changed from loadURL does not support synchronous requests. patch attached. to loadURL does not support synchronous requests

  Changed 6 years ago by crschmidt

  • state changed from Needs Discussion to Awaiting User Feedback

  Changed 5 years ago by rdewit

  • state changed from Awaiting User Feedback to Needs Discussion

My reason for coming up with this whole thing was to have an easy 1 line way of fetching an external XML document (since the request will be done in several places in KML.js). The returned value would be the responseText.

Looking into it again and just having seen issue #964 where loadURL now returns the request object, this would be inconsistent behaviour. To be consistent, I would now need an extra line of code for fetching the request.transport.responseText anyway.

So, Chris, I will drop the issue and will be happy to have it marked as 'wontfix'. Still curious what you thought that I might have been thinking though. ;-)

  Changed 5 years ago by crschmidt

  • status changed from new to closed
  • state Needs Discussion deleted
  • resolution set to wontfix
            new OpenLayers.Ajax.Request("webprocessingserver/wps.cgi/" +
                                        type + ".geojson" + paramString,
                         {   method: 'post',
                             postBody: data,
                             onComplete: update,
                             requestHeaders: ['Content-type', 'application/json']
                          }
                         );

One line of JS to open an Ajax.Request -- which if set to synchronous, will return the content, I believe? In any case, I don't know that 'Easy, one-line way" really has any meaning, since it's just as easy with Ajax.Request as with loadURL based on my reading.

The bug that exists in Ajax.Request is that it doesn't take into account OpenLayers.ProxyHost -- which OpenLayers.loadURL does. We can likely fix this by moving the ProxyHost down a level. This is the only real thing that we should probably fix -- and if someone wants to 'own' that task, they should open a new ticket. :)

Note: See TracTickets for help on using tickets.