0

Getting below error on requesting from localhost:-

XMLHttpRequest cannot load http://192.168.1.3:5080/openmeetings/services/user/login?user=user&pass=pass. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access.

Code is written as

<script>
        $(document).ready(function(){
            $("#meet").click(function(){
                $.ajax({
                    method: "GET",
                    url: "'.$server.'services/user/login",
                    data: {user: "user", pass: "pass"},
                    dataType: "json",
                    success : function(data){
                    if(data["serviceResult"]["code"]==1){
                        var code = data["serviceResult"]["message"];
                        $.ajax({
                        method: "POST",
                        url: "'.$server.'services/user/hash?sid=" + code ,
                        data: {user: JSON.stringify({
                            firstname: "Edubeans",
                            lastname: "Student",
                            externalId: "uid1",
                            externalType: "myCMS",
                            login: "pivotal"
                        }),
                        options: JSON.stringify({
                            roomId: 7,
                            moderator: true,
                            showAudioVideoTest: true
                        })
                         },
                         dataType: "json",
                         success : function(data1){
                         $("#link").html(\'<a href="'.$server.'hash?secure=\'+data1["serviceResult"]["message"]+\'&language=1" target="_blank">Please click here to Enter the room.</a>\');     
                    }


                })                                      
                }
            }
        });                                     
    });                 
});
</script>
  • Thanks but Question you refer to is only redirecting to disable web security in web browsers this is not the solution i want because we cant tell end user to use the website by disabling web security. – Vikas Sharma Sep 19 '17 at 06:38

1 Answers1

0

Your origin is localhost but you are trying to access another origin that is located in 192.168.1.3.

Change 192.168.1.3 to localhost

or

Instead of executing your code from http://localhost execute it from http://192.168.1.3

Justinas
  • 41,402
  • 5
  • 66
  • 96
  • First if i change 192.168.1.3 to localhost then the openmeetings will not be accessable because it is on same network not on same sysytem. Second if i am executing code from same computer and change url to http://localhost:5080 still getting same error because i am requesting from the localhost port 80 and and OM listens on port 5080 . This is treated as cross-domain also. – Vikas Sharma Sep 19 '17 at 06:31