how to make an Ajax call?

All you've ever wanted to know about the ActiveX, Mozilla plugins, the web interface and various PHP extensions
hb9iiu
New Cone
New Cone
Posts: 1
Joined: 27 May 2022 18:09

how to make an Ajax call?

Postby hb9iiu » 27 May 2022 18:24

Hi

I have an older application that used below to control VLC via an Ajax call

Code: Select all

$.ajax({ url: "http://192.168.0.76:8080/requests/status.xml?command=pl_next" });
Now I understand that http requests need a password.

I tried this url in the browser, and it works

Code: Select all

http://:mypassword@192.168.0.76:8080/requests/status.xml?command=pl_next

but it does not when using it in the Ajax call

Code: Select all

$.ajax({ url: "http://:mypassword@192.168.0.76:8080/requests/status.xml?command=pl_next" });
Can someone help?

Thanks

Daniel

emcodem
Blank Cone
Blank Cone
Posts: 10
Joined: 05 Jul 2022 12:12

Re: how to make an Ajax call?

Postby emcodem » 20 Jul 2022 16:56

$.ajax implies that you want to do that in a browser, most likely from a different webserver than vlc's builtin one. That again means that your problem is CORS.
VLC webserver does not allow CORS because the responses of the builtin webserver do not include the "access-control" headers for some reason.
That means you cannot access anything directly from the browser. Instead you need to either proxy calls to VLC on your own webserver or you run your page using VLC's builtin webserver.
E.g. alter the files in VLC\lua\http\

Another solution and discussion about this is here:
https://code.videolan.org/videolan/vlc/-/issues/8848

On the other hand, if this is just about the authentification part, look up how to add "auth basic" headers with ajax.


Return to “Web and scripting”

Who is online

Users browsing this forum: No registered users and 8 guests