Changeset 2005
- Timestamp:
- 03/18/10 11:05:57 (4 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
core/trunk/geoext/lib/overrides/override-ext-ajax.js
r1998 r2005 30 30 request: function(method, uri, cb, data, options) { 31 31 options = options || {}; 32 method = method || options.method; 32 33 var hs = options.headers; 33 34 if(options.xmlData) { … … 36 37 hs["Content-Type"] = "text/xml"; 37 38 } 38 method = (method ? method : 39 (options.method ? options.method : "POST")); 39 method = method || "POST"; 40 40 data = options.xmlData; 41 41 } else if(options.jsonData) { … … 44 44 hs["Content-Type"] = "application/json"; 45 45 } 46 method = (method ? method : 47 (options.method ? options.method : "POST")); 46 method = method || "POST"; 48 47 data = typeof options.jsonData == "object" ? 49 48 Ext.encode(options.jsonData) : options.jsonData; 50 49 } 51 // options.form or options.params means form-encoded data, so change content-type 52 if ((options.form || options.params) && (!hs || !hs["Content-Type"])) { 50 // if POST method, options.form or options.params means 51 // form-encoded data, so change content-type 52 if ((method && method.toLowerCase() == "post") && 53 (options.form || options.params) && 54 (!hs || !hs["Content-Type"])) { 53 55 hs = hs || {}; 54 56 hs["Content-Type"] = "application/x-www-form-urlencoded"; core/trunk/geoext/tests/lib/overrides/override-ext-ajax.html
r2004 r2005 188 188 189 189 } 190 191 function test_paramsGet(t) { 192 t.plan(0); 193 /* 194 * Setup 195 */ 196 setup(); 197 198 var proto = OpenLayers.Request.XMLHttpRequest.prototype; 199 var _srh = proto.setRequestHeader; 200 proto.setRequestHeader = function(k, v) { 201 t.eq(k == "Content-Type" && v != "application/x-www-form-urlencoded", 202 "Content-Type header should not be set for GET request"); 203 }; 204 Ext.Ajax.request({ 205 failure: function(response) { }, 206 method: 'GET', 207 success: function(response) { }, 208 params: { xx: 'xx', yy: 'yy'}, 209 url: 'foo.php' 210 }); 211 proto.setRequestHeader = _srh; 212 213 /* 214 * Teardown 215 */ 216 teardown(); 217 } 190 218 </script> 191 219 <body>