简体   繁体   中英

AJAX call url does not work

I am designing a webpage to play and control an IP camera that can move up/down, zoom in/out, etc. To make those movements we have to call a url. As I am playing the content from the webcam, I have to do these calls asynchronously. I have tried to do it with AJAX but there is no result.

$(document).ready(function(){
    $("#up").click(function(){
        $.ajax({
            url: "http://192.168.1.101:88/cgi-bin/CGIProxy.fcgi?cmd=ptzMoveUp&usr=admin&pwd=", 
            success: function(result){
                $("#div1").html('Moving UP');
            }
        });
     });
 });
</script>

...

<button id="up" class="arrow" type="button"><b>UP</b></button>
...
<div id="div1"><h2>This text doesn't change</h2></div>

Your jQuery selector is wrong. Change:

$(".up").click(function(){....

( . implies up is a class)

to:

$("#up").click(function(){....

( # implies up is an id)

Further reading on jQuery selectors:

https://api.jquery.com/category/selectors/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM