简体   繁体   中英

Javascript POST request for Update, no HTML text update

I have been writting a CMS, and im currently working on a remote Updater script, so users can update the CMS with a click of a button. Problem is, i cant see to get this JS snippet below to work:

    <script type="text/javascript">
    $(document).ready(function() {
        $('#update').html('Checking for updates...');
        check();
      });

    //function to check for new updates
    function check(){

        //use ajax to run the check
        $.post("http://updateserver.come/get_update.php", { version: cms_version },
            function(result){
                //if the result is 1
                if(result == 1){
                    //show that there are updates
                    $('#update').html('Updates is Available');
                }else{
                    //show that there are NO updates
                    $('#update').html('Updates are not Available');
                }
        });

    }
    </script>

<div id="update"></div>

The problem is, when JS gets the response, it doesnt update the text between the divs. Anyone have a clue why this is?

Web applications are limited by the so-called Same Origin Policy , which restricts requests to the same domain. If your app doesn't live in the same domain as the web service you're trying to POST to, the browser won't let it happen.

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