News for hackers. Stuff that matters.
Re:jQuery 1.3 ßeta by mlLK on Monday December 22, 2008 @01:31PM (#406652)
I'd like a more expansive AJAX API that is capable of handling HTTP headers.
Re:jQuery 1.3 ßeta by jeresig on Monday December 22, 2008 @01:40PM (#406668)
"capable of handling HTTP headers" - can you expand on this a bit?

Right now you can set HTTP headers in jQuery like so:

    $.ajax({
      beforeSend: function(xhr){
        xhr.setRequestHeader("Accept","application/json");
      },
      ... other options ...
    });
More info: http://docs.jquery.com/Ajax/jQuery.ajax#options
Re:jQuery 1.3 ßeta by ars on Monday December 22, 2008 @02:15PM (#406746)
I'd like it that if the server sent back Content-type: application/json then jquery would automatically put it in json, and not require dataType: 'json'.

And it would really be nice if the "simple" ajax functions also allowed doing something if there was an error.

Re:jQuery 1.3 ßeta by mmj on Monday December 22, 2008 @02:41PM (#406782)
That is a pretty niche feature, I personally wouldn't do something like that.

Check out getResponseHeader() if you are so inclined.

As for the errors, there are many ways to check for "ajax" errors, for one thing you can check the status or statusText property.

Re:jQuery 1.3 ßeta by ars on Monday December 22, 2008 @03:14PM (#406825)
Niche? I guess you don't use json. jquery already autodetects xml, why not json too? It's not even hard - it's right in the content type.

I know how to detect errors, that was hardly my point. I was suggesting an improvement, not tech support.

Re:jQuery 1.3 ßeta by mmj on Monday December 22, 2008 @05:52PM (#406978)
You don't have to eval xml.
Re:jQuery 1.3 ßeta by natrius on Monday December 22, 2008 @07:30PM (#407060)
You don't have to eval JSON.

http://www.json.org/js.html

Re:jQuery 1.3 ßeta by mmj on Tuesday December 23, 2008 @10:09AM (#407587)
http://www.json.org/json2.js

// In the third stage we use the eval function to compile the text into a

// JavaScript structure. The '{' operator is subject to a syntactic ambiguity

// in JavaScript: it can begin a block or an object literal. We wrap the text

// in parens to eliminate the ambiguity.

Re:jQuery 1.3 ßeta by ars on Tuesday December 23, 2008 @12:09PM (#407778)
http://www.json.org/json_parse.js

// This is a function that can parse a JSON text, producing a JavaScript

// data structure. It is a simple, recursive descent parser. It does not use

// eval or regular expressions, so it can be used as a model for implementing

// a JSON parser in other languages.

Re:jQuery 1.3 ßeta by mmj on Tuesday December 23, 2008 @02:10PM (#407954)
Yes, but even better would be to use jQuery's excellent JSONP method.