jquery - No access Control Origin -


i getting following error no 'access-control-allow-origin' header present on requested resource. origin 'http://localhost:8080' therefore not allowed access.when execute below code not have access code in http://localhost:8983 can modify 8080 port server code. below code

<!doctype html> <html lang="en"> <head>   <meta charset="utf-8">   <title>jquery ui autocomplete - default functionality</title>   <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">   <script src="//code.jquery.com/jquery-1.10.2.js"></script>   <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>    <script>   $(function() {       $( "#name" ).autocomplete({       source: function(request,response){              var name = $("#name").val();            $.ajax({               type:"get",         //    contenttype: "application/json; charset=utf-8",               url: "http://localhost:8983/solr/test/suggest",               data: "suggest=true&suggest.build=true&suggest.dictionary=mysuggester&wt=json&suggest.q="+name,         //      url: "./search.html",         //   data: "name=" + name,               success: function (data) {                   if (data != null) {                        alert(data);                   }               },               error: function(result) {                   alert("error");               }           })       }     });      $("#search").click(function () {           var name = $("#name").val();           $.ajax({             type: "get",              url: "./search.html",              data: "name=" + name,              success: function(response){                     // have response                     $('#results').html(response);                      },                      error: function(e){                      alert('error: ' + e);                  }           });       });          });   </script> </head> <body>  <div class="ui-widget">   <label for="tags"> </label>   <input id="name">   <input type="button" name="search" id="search" value="submit" />  </div>     <div id="results"></div>  </body> </html> 

i think want understand how cors works: https://developer.mozilla.org/en-us/docs/web/http/access_control_cors

you'll need make modifications server side allow requests.


Comments