Bug Tracker

Changeset 4650

Show
Ignore:
Timestamp:
02/05/08 20:05:23 (10 months ago)
Author:
malsup
Message:

Use core httpData method and fix unit test.

Location:
trunk/plugins/form
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/plugins/form/jquery.form.js

    r4488 r4650  
    11/* 
    22 * jQuery Form Plugin 
    3  * version: 2.03 (01/20/2008) 
     3 * version: 2.04 (02/05/2008) 
    44 * @requires jQuery v1.1 or later 
    55 * 
     
    193193 
    194194    var a = this.formToArray(options.semantic); 
    195     if (options.data) { 
    196         for (var n in options.data) 
    197             a.push( { name: n, value: options.data[n] } ); 
    198     } 
     195    if (options.data) { 
     196        for (var n in options.data) 
     197            a.push( { name: n, value: options.data[n] } ); 
     198    } 
    199199 
    200200    // give pre-submit callback an opportunity to abort the submit 
     
    327327                xhr.responseText = doc.body ? doc.body.innerHTML : null; 
    328328                xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc; 
     329                xhr.getResponseHeader = function(header){ 
     330                    var headers = {'content-type': opts.dataType}; 
     331                    return headers[header]; 
     332                }; 
    329333 
    330334                if (opts.dataType == 'json' || opts.dataType == 'script') { 
    331335                    var ta = doc.getElementsByTagName('textarea')[0]; 
    332                     data = ta ? ta.value : xhr.responseText; 
    333                     if (opts.dataType == 'json') 
    334                         eval("data = " + data); 
    335                     else 
    336                         $.globalEval(data); 
     336                    xhr.responseText = ta ? ta.value : xhr.responseText; 
    337337                } 
    338                 else if (opts.dataType == 'xml') { 
    339                     data = xhr.responseXML; 
    340                     if (!data && xhr.responseText != null) 
    341                         data = toXml(xhr.responseText); 
     338                else if (opts.dataType == 'xml' && !xhr.responseXML && xhr.responseText != null) { 
     339                    xhr.responseXML = toXml(xhr.responseText); 
    342340                } 
    343                 else { 
    344                     data = xhr.responseText; 
    345                 } 
     341                data = $.httpData(xhr, opts.dataType); 
    346342            } 
    347343            catch(e){ 
  • trunk/plugins/form/test/index.html

    r2234 r4650  
    152152    $('#form1').clearForm(); 
    153153    val = $el.val(); 
    154     ok( '' == val, 'success: ' + val); 
     154    ok( !val, 'success: ' + val); 
    155155}); 
    156156