Changeset 1717
- Timestamp:
- 2010-09-30 12:49:43 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/kauri-forms/kauri-forms-framework/src/main/kauri/static-{build}.key/kauri.forms/field.js
r1648 r1717 203 203 var uri = this.uri.expand(this.uriContext); 204 204 var me = this; 205 var callback = function( data) { 206 207 me.parseOptions(data); 205 var onSuccess = function( data, status, xhr) { 206 if (xhr && me.lastXhr == xhr) { //ignore responses that are not linked to the last request 207 me.parseOptions(data); 208 me.lastXhr = null; 209 } 208 210 }; 209 var errorcallback = function( data) { 210 211 me.clearOptions(data); 211 var onError = function( xhr, status, err) { 212 if (xhr && me.lastXhr == xhr) { 213 me.clearOptions(); 214 me.lastXhr = null; 215 } 212 216 }; 213 217 214 $.ajax( { 218 // assign lastXhr to make sure only the return of this last one is accepted 219 this.lastXhr = $.ajax( { 215 220 // take async setting from setup 216 type :"GET",217 url :uri,218 processData :false,219 dataType :"json",220 success :callback,221 error :errorcallback,222 beforeSend : function(xhr) {223 // setting datatype to json should be enough, unfortunately224 // the restlet content negotiation chokes on the resulting225 // accept header: application/json, text/javascript, */*226 // and doesn't prefer the json variant.227 // see issue #95228 xhr.setRequestHeader("Accept", "application/json");221 type : "GET", 222 url : uri, 223 processData: false, 224 dataType : "json", 225 success : onSuccess, 226 error : onError, 227 beforeSend : function(xhr) { 228 // setting datatype to json should be enough, unfortunately 229 // the restlet content negotiation chokes on the resulting 230 // accept header: application/json, text/javascript, */* 231 // and doesn't prefer the json variant. 232 // see issue #95 233 xhr.setRequestHeader("Accept", "application/json"); 229 234 } 230 235 }); … … 304 309 * @param {Array} data 305 310 */ 306 Options.prototype.clearOptions = function( data) {311 Options.prototype.clearOptions = function( ) { 307 312 308 313 this.set([], []);
Note: See TracChangeset
for help on using the changeset viewer.