[Phpmyadmin-devel] URL parameter separator and Jquery - #3733

Michal Čihař michal at cihar.com
Mon Apr 14 09:05:02 CEST 2014


Hi

Dne Sun, 13 Apr 2014 15:30:57 +0200
Hugues Peccatte <hugues.peccatte at gmail.com> napsal(a):

> I'm working on bug ticket http://sourceforge.net/p/phpmyadmin/bugs/3733/
> I already replaced all & in PHP files by the separator defined in php.ini.
> I also replaced a part of & in JS files (almost all). But I still have an
> issue... with Jquery method $.get...
> 
> This method have many parameters, and one could be a JSON object of URL
> parameters.
> Something like this:
>     var params = {
>         aPath: $expandElem.find('span.aPath').text(),
>         vPath: $expandElem.find('span.vPath').text()
>     };
> And this:
> $.get(url, params, function (data) {
> ...
> });

It seems to be hardcoded within jQuery.param(). On the other side, if
you give jQuery.get() a string as a params, it will use it as it is. So
we can introduce our own function to do the array to string conversion,
which will use correct separator, something like (completely not
tested):

function PMA_URL_params(params) {
   var s = [];
   $.each(params, function() {
     s[s.length] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
   });
   return s.join(SEPARATOR);
}

$.get(url, PMA_URL_params(params), function (data) {
...
});

-- 
	Michal Čihař | http://cihar.com | http://phpmyadmin.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://lists.phpmyadmin.net/pipermail/developers/attachments/20140414/6603c3f4/attachment.sig>


More information about the Developers mailing list