[Encoding] in_play&input don't work when send via $.Ajax

All you've ever wanted to know about the ActiveX, Mozilla plugins, the web interface and various PHP extensions
blck
New Cone
New Cone
Posts: 3
Joined: 29 Sep 2013 18:55

[Encoding] in_play&input don't work when send via $.Ajax

Postby blck » 29 Sep 2013 19:29

Hi,
I'm currently developing an web application using jQuery-Ajax to send commands to the vlc-webserver. I was surprised how easy it is, basically. But I got stuck at the command "in_play&input=". Here is the send-command-function I use:

Code: Select all

Player.prototype.sendCommand = function(params, append) { $.ajax({ url: 'http://' + data.ip + ":" + data.port + '/requests/status.xml', data: params, success: function (data, status, jqXHR) { console.log(data); }, error: function(data){ console.log("fail") } }); }
Basically I'm sending the following parameter to my send-command-function:

Code: Select all

in_play&input=file:///home/vlc/Musik/Artist/The%20Chicago%20Story_%20The%20Complete%20Greatest/03%20You're%20The%20Inspiration.m4a
(if I use the javascript-function encodeURI on the file-path I get) or

Code: Select all

in_play&input=file%3A%2F%2F%2Fhome%2Fvlc%2FMusik%2FArtist%2FThe%20Chicago%20Story_%20The%20Complete%20Greatest%2F03%20You're%20The%20Inspiration.m4a
(if I use the javascript-function encodeURIComponent on the file-path I get)

This won't work. However if I the first line and paste it in the browser like so:

Code: Select all

http://IP:PORT/requests/status.xml?command=in_play&input=file:///home/vlc/Musik/Artist/The%20Chicago%20Story_%20The%20Complete%20Greatest/03%20You're%20The%20Inspiration.m4a


It seemed to work, but as I was posting the content of the addressbar of my browser into this forum, it did look like this:

Code: Select all

http://IP:PORT/requests/status.xml?command=in_play&input=file:///home/vlc/Musik/Artist/The%20C%E2%80%A6e%20Complete%20Greatest/03%20You%27re%20The%20Inspiration.m4a
This conversion happens automatically. My question now: Since this is obviously a thing of the correct encoding - which method to I have to use? How do I encode my string in the right way?

Thank you very much,
blck

P.S.

encodeURIComponent does work for request/browse.xml - I'm getting confused :roll:

Return to “Web and scripting”

Who is online

Users browsing this forum: No registered users and 18 guests