jQuery load access denied

Asked

Viewed 77 times

0

I am facing a problem already known by many, in IE it is possible to use Activex to get the user logged in to the network.
In Chrome this is not possible and after many searches I got the same answer.
I know there is a library in Java that can get this information independent of the browser, but the project is too small and I don’t have all the understanding to use the whole structure of Java, so it should be developed in PHP even using a simple server with Tomcat.
As solution attempt was developed a URL using Java that returns the user and only the user even more nothing.
However I can not handle this information tried via load, ajax, json, jsonp, but always return me an impossibility access.
Via $("p").html('<object data="url/login" />') I can print the information on the page but I can’t convert to string to use it.

If someone can give me a light as a solution to this would be very grateful. Thank you.

1 answer

1


the $().load is not used to insert DOM into the page, it is used for HTML content requests generated by the back end for popular front end elements, if you want to load an Object element do so:

$("p").html('<object data="url/login" />');

Now if you just want to get back-end information on a request I think what you’re looking for is something like:

$.ajax("url/login", {
    "cache": false
}).done(function(resposta) {
    alert(resposta);
}).fail(function(erro) {
    alert(erro);
});

If the back-end data is json, then do so:

$.ajax("url/login", {
    "dataType": "json",
    "cache": false
}).done(function(resposta) {
    console.log(resposta);//Imprime no console
}).fail(function(erro) {
    alert(erro);
});
  • The return of Object was in html even though I confused :). Now when running ajax the console returns me the message: GET http://server2/User/id?=1473351041784 user.php:1 Xmlhttprequest cannot load http://server2/Usuario/id?=1473351041784. No 'Access-Control-Allow-Origin' header is present on the requested Resource. Origin 'http://server1' is therefore not allowed access. The Response had HTTP status code 401. I am on server 1 and trying to perform ajax in 2 there is some specific release that should be done there?

  • If used jsonp the console returns - id? callback=jQuery1122019...1473351903903&=1473351903904:1 Uncaught Syntaxerror: Invalid or Unexpected token - and by clicking on the link I can see the result on the console.

  • @Cleverson I did not speak jsonp I spoke json, they are two different things. Tell me your return is json even? Because if it’s not there’s no point in using dataType

  • @Cleverson on the Access-Control-Allow-Origin, this error occurs due to different sources, please read more on: http://answall.com/search?q=Access-Control-Allow-Origin

  • Because I am on a different server I believe that is why json gives HTTP error, I will read there.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.