I ran into the same bug as well.
The patch would work unless the attribute itself has quotes in it, which 
would need to be escaped:
http://stackoverflow.com/questions/4015345/how-to-properly-escape-quotes-inside-html-attributes


On Thursday, June 21, 2012 11:50:34 AM UTC-7, Thomas Le wrote:
>
> Hey guys,
>
> I found a small bug in the ajax function when you pass in field input 
> names like "field[location]" or "blog[id]".
>
> So, if I have a form that looks like:
>
> <input type="text" name="query" value="">
> <label class="control-label" for="searchSource">Search Source:</label>
> <select type="text" name="searchSource">
>     <option value="resumes" selected="selected">Resumes</option>
>     <option value="openWeb">Open Web</option>
> </select>
> <label class="control-label" for="location">Location:</label>
> <input type="text" name="field[location]" value="">
> <label class="control-label" for="experience">Experience:</label>
> <input type="text" name="field[experience]" value="">
> <label class="control-label" for="education">Education:</label>
> <input type="text" name="field[education]" value="">
>
> And I pass all the input field names through ajax(u, t, s) in an array to 
> parameter t:
>
> var t = [ 'query', 'searchSource', 'field[location]', 'field[experience]' 
> ];
>
> This function fails to execute (located in app_name/static/js/web2py.js)
>
> function ajax(u,s,t) {
>     query = '';
>     if (typeof s == "string") {
>         d = jQuery(s).serialize();
>         if(d){ query = d; }
>     } else {
>         pcs = [];
>         if (s != null && s != undefined) for(i=0; i<s.length; i++) {
>             q = jQuery("[name="+s[i]+"]").serialize();
>             if(q){pcs.push(q);}
>         }
>         if (pcs.length>0){query = pcs.join("&");}
>     }
>     jQuery.ajax({type: "POST", url: u, data: query, success: function(msg) 
> { if(t) { if(t==':eval') eval(msg); else if(typeof t=='string') 
> jQuery("#"+t).html(msg); else t(msg); } } });
> }
>
> More specifically, this line:
>
> q = jQuery("[name="+s[i]+"]").serialize();
>
> To fix, add single quotes around s[i], like this:
>
> q = jQuery("[name='"+s[i]+"']").serialize();
>
>
>
>

-- 



Reply via email to