jonsmau 1 Posted August 5, 2013 Report Share Posted August 5, 2013 (edited) Estou a desenvolver uma aplicação Web no netbeans e preciso de usar um WebService criado em asp.net. Para aceder ao WebService estou a usar uma função jQuery no HTML. O exemplo da função jQuery e o código HTML que uso é o seguinte: <html> <head id="Head1" runat="server"> <title></title> <script type="text/javascript" src="jquery-1.3.2.js"></script> <script type="text/javascript"> function serviceCall() { $.ajax({ type: "POST", url: 'http://localhost:6335/Service1.asmx?op=TestMethod' data: null, contentType: "application/json; charset=utf-8", dataType: "json", success: function (msg) { alert("entrou!"); $("#divResult").html(msg.d); }, error: function (e) { alert("não deu"); $("#divResult").html("WebSerivce unreachable"); } }); } </script> </head> <body> <form id="form1" runat="server"> <div style="width: 100px; height: 30px; background-color: yellow;" onclick="serviceCall();"> Click me</div> <div id="divResult" style="margin-top: 20px;" runat="server"> </div> </form> </body> </html> E o código do WebService: namespace WebService1 { [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [system.ComponentModel.ToolboxItem(false)] [system.Web.Script.Services.ScriptService] public class Service1 : System.Web.Services.WebService } Ao executar a aplicação Web o erro que me aparece é o seguinte: Origin http://localhost:8084 is not allowed by Access-Control-Allow-Origin. Alguém conhece uma solução que me possa ajudar? Edited August 5, 2013 by jonsmau Link to post Share on other sites
ErasedGOD 0 Posted August 5, 2013 Report Share Posted August 5, 2013 tens isso bem configurado? url: 'http://localhost:6335/Service1.asmx?op=TestMethod' vs http://localhost:8084 ? Link to post Share on other sites
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now