Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Adding missing AjaxOptions #259

Merged
merged 2 commits into from

2 participants

@michaelaird

I just went through the docs and noticed some AjaxOptions were missing.

@nikhilk
Owner

Can any of the dictionaries be more strongly typed? Example:

Dictionary<string, string> Accepts, Contents, Headers
Dictionary<int, Action> StatusCode
Dictionary<string, Func<string, object>> Converters
@michaelaird
@michaelaird

I've updated the changes but i'm a little concerned about the StatusCode. The docs say this:

If the request is successful, the status code functions take the same parameters as the success callback; if it results in an error, they take the same parameters as the error callback.

Is there a "clean" way to provide these 2 different signatures?

@nikhilk
Owner

One way would be to create a special type, rather than use a Dictionary with multiple indexers - one for Action, another for the success callback, and another for errors... though I feel its starting to take on a bit of overkill.

If they're uncommon, leave it as you have it right now, and within the method, one can use Arguments to get the value in a late-bound way.

jQuery never ceases to make me wonder - why so many ways to do the same thing?

@michaelaird

I think i'll leave it as-is and see if we get feedback. Clearly people haven't been missing these options...

@nikhilk nikhilk merged commit d159aa4 into nikhilk:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 9, 2012
  1. @michaelaird
Commits on Oct 10, 2012
  1. @michaelaird
This page is out of date. Refresh to see the latest.
Showing with 72 additions and 0 deletions.
  1. +72 −0 src/Libraries/jQuery/jQuery.Core/jQueryAjaxOptions.cs
View
72 src/Libraries/jQuery/jQuery.Core/jQueryAjaxOptions.cs
@@ -33,6 +33,18 @@ public sealed class jQueryAjaxOptions {
}
/// <summary>
+ /// Gets or sets the content type sent in the request header that tells the server what kind of response it will accept in return.
+ /// </summary>
+ [IntrinsicProperty]
+ public Dictionary<string, string> Accepts {
+ get {
+ return null;
+ }
+ set {
+ }
+ }
+
+ /// <summary>
/// Gets or sets whether the request is async.
/// </summary>
[IntrinsicProperty]
@@ -82,6 +94,18 @@ public sealed class jQueryAjaxOptions {
}
/// <summary>
+ /// Gets or sets a map of string/regular-expression pairs that determine how jQuery will parse the response, given its content type.
+ /// </summary>
+ [IntrinsicProperty]
+ public Dictionary<string, RegularExpression> Contents {
+ get {
+ return null;
+ }
+ set {
+ }
+ }
+
+ /// <summary>
/// Gets or sets the content type of the data sent to the server.
/// </summary>
[IntrinsicProperty]
@@ -106,6 +130,30 @@ public sealed class jQueryAjaxOptions {
}
/// <summary>
+ /// Gets or sets a map of dataType-to-dataType converters.
+ /// </summary>
+ [IntrinsicProperty]
+ public Dictionary<string, Func<string, object>> Converters {
+ get {
+ return null;
+ }
+ set {
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets if you wish to force a crossDomain request (such as JSONP) on the same domain, set the value of crossDomain to true
+ /// </summary>
+ [IntrinsicProperty]
+ public bool CrossDomain {
+ get {
+ return false;
+ }
+ set {
+ }
+ }
+
+ /// <summary>
/// Gets or sets the data to be sent to the server.
/// </summary>
[IntrinsicProperty]
@@ -154,6 +202,18 @@ public sealed class jQueryAjaxOptions {
}
/// <summary>
+ /// Gets or sets if a map of additional header key/value pairs to send along with the request.
+ /// </summary>
+ [IntrinsicProperty]
+ public Dictionary<string, string> Headers {
+ get {
+ return null;
+ }
+ set {
+ }
+ }
+
+ /// <summary>
/// Gets or sets whether the request is successful only if its been modified since
/// the last request.
/// </summary>
@@ -252,6 +312,18 @@ public sealed class jQueryAjaxOptions {
}
/// <summary>
+ /// Gets or sets a map of numeric HTTP codes and functions to be called when the response has the corresponding code.
+ /// </summary>
+ [IntrinsicProperty]
+ public Dictionary<int, Action> StatusCode {
+ get {
+ return null;
+ }
+ set {
+ }
+ }
+
+ /// <summary>
/// Gets or sets the function to invoke upon successful completion of the request.
/// </summary>
[IntrinsicProperty]
Something went wrong with that request. Please try again.