|
Revision 7335, 1.9 kB
(checked in by tschaub, 7 months ago)
|
Adding cross-browser XMLHttpRequest functionality and convenience methods around it in the OpenLayers.Request namespace. Deprecating OpenLayers.Ajax.Request. Full support sync/async requests using all HTTP verbs now. r=elemoine (closes #1565)
|
- Property svn:eol-style set to
native
|
| Line | |
|---|
| 1 |
<html xmlns="http://www.w3.org/1999/xhtml"> |
|---|
| 2 |
<head> |
|---|
| 3 |
<title>XHR Acceptance Test</title> |
|---|
| 4 |
<script src="../../lib/OpenLayers.js"></script> |
|---|
| 5 |
<script type="text/javascript"> |
|---|
| 6 |
var url = "ajax.txt"; |
|---|
| 7 |
function sendSynchronous(){ |
|---|
| 8 |
var request = OpenLayers.Request.GET({ |
|---|
| 9 |
url: url, |
|---|
| 10 |
async: false, |
|---|
| 11 |
callback: function() { |
|---|
| 12 |
document.getElementById('send_sync').value += 'request completed\n'; |
|---|
| 13 |
} |
|---|
| 14 |
}); |
|---|
| 15 |
document.getElementById('send_sync').value += 'other processing\n'; |
|---|
| 16 |
} |
|---|
| 17 |
function sendAsynchronous(){ |
|---|
| 18 |
var request = OpenLayers.Request.GET({ |
|---|
| 19 |
url: url, |
|---|
| 20 |
callback: function() { |
|---|
| 21 |
document.getElementById('send_sync').value += 'request completed\n'; |
|---|
| 22 |
} |
|---|
| 23 |
}); |
|---|
| 24 |
document.getElementById('send_sync').value += 'other processing\n'; |
|---|
| 25 |
} |
|---|
| 26 |
function sendAndAbort(){ |
|---|
| 27 |
var request = OpenLayers.Request.GET({ |
|---|
| 28 |
url: url, |
|---|
| 29 |
callback: function() { |
|---|
| 30 |
document.getElementById('send_sync').value += 'never called\n'; |
|---|
| 31 |
} |
|---|
| 32 |
}); |
|---|
| 33 |
request.abort(); |
|---|
| 34 |
document.getElementById('send_sync').value += 'other processing\n'; |
|---|
| 35 |
} |
|---|
| 36 |
|
|---|
| 37 |
</script> |
|---|
| 38 |
</head> |
|---|
| 39 |
<body > |
|---|
| 40 |
<button onclick="sendSynchronous()">synchronous</button> |
|---|
| 41 |
expected output: "request completed" then "other processing"<br /> |
|---|
| 42 |
<button onclick="sendAsynchronous()">asynchronous</button> |
|---|
| 43 |
expected output: "other processing" then "request completed"<br /> |
|---|
| 44 |
<button onclick="sendAndAbort()">send and abort</button> |
|---|
| 45 |
expected output: "other processing" (and not "never called")<br /> |
|---|
| 46 |
<textarea id="send_sync" rows="6"></textarea><br /> |
|---|
| 47 |
<button onclick="document.getElementById('send_sync').value = ''">Clear</button> |
|---|
| 48 |
</body> |
|---|
| 49 |
</html> |
|---|