Jump to content
RicardoCostaTW

Pedido Request CTT

Recommended Posts

RicardoCostaTW

Olá Pessoal,

Estou a fazer um trabalho para a univ, e estou fazer um request aos ctt, para saber a localização de um objecto, mas dá me sempre erro :X

Diz sempre canceled. já ando aqui há imenso tempo e não sei porque.

Alguém me dá uma dica?

<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
   <head>
    <meta charset="UTF-8">
    <title></title>
   </head>
   <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
   <script>
$(function(){
$('#enviar').click(function(){

   jQuery.ajax({
  type: 'POST',
  data: 'objects=&showResults=true&pesqObjecto.objectoId=RC992163877PT',
  url:'http://www.ctt.pt/feapl_2/app/open/objectSearch/cttObjectSearch.jspx',
  contentType:'application/x-www-form-urlencoded',

    success: function(retorno){
    alert(retorno);
  },error: function(xhr,status,err){
		 alert("DEBUG: status"+status+" \nError:"+err+"-->"+xhr.statusText);
	 }
   });
});
});

   </script>
   <body >

    <input id="enviar" type="button" onclick=""/>
    <input id="result" type="text" />
   </body>
</html>

Share this post


Link to post
Share on other sites
Devexz

XMLHttpRequest cannot load http://www.ctt.pt/feapl_2/app/open/objectSearch/cttObjectSearch.jspx. No 'Access-Control-Allow-Origin' header is present on the requested resource.

As the source (origin) page and the target URL are at different domains, your code is actually attempting to make a Cross-domain (CORS) request, not an ordinary GET.

In a few words, the same-origin policy enforces that browsers only allow Ajax calls to services in thesame domain as the HTML page.

http://stackoverflow.com/questions/19821753/jquery-xml-error-no-access-control-allow-origin-header-is-present-on-the-req

Eu acho que existem maneiras de contornar esta situação...


Contador de calorias: caloriaspordia.com

Share this post


Link to post
Share on other sites
RicardoCostaTW

Já arranjei uma maneira, muito obrigado!

Edited by RicardoCostaTW

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.