0

I'm looking for something. The problem is that I want to make my app do more locally and less remote.

It needs to put a parameter in every request (or websession id)

I tried the following

  $.getJSON('http://*******************.com/loginapi.php?uuid=0x1a2b3c4e', function(jd) {
          var reg = jd.usrreg;
          var uuid = jd.usrpin;
          var usrid = jd.usrid;     
      });

 });

That does nothing, on the server side I don't even see a request to that page.

document.write(uuid) does not give anything back, when I go in my browser to the requested page I see the following:

{"usrreg":"0","usrpin":"0x1a2b3c4e","usrid":"0"}

I also tried with form data, so when I press login it sends a request to the server, but I should still get something back like usrreg=0 or 1, because it means the person is not registered, or usrreg=2 for wrong user/pass.

How can I read the value that I get when I open the page?

putvande
  • 15,068
  • 3
  • 34
  • 50
  • Form data seems to work, it's just that you give loginapi.php bad parameters. Or something. We don't know the contents of loginapi.php so we can't help you there. Have you tried using $.ajax() instead? – nyson Jul 27 '13 at 09:45
  • See: [How to use jQuery AJAX for an outside domain?](http://stackoverflow.com/q/1489373/1935077) – Petr R. Jul 27 '13 at 10:04
  • In your example code you also have a `})` to many. Is that a typo? – putvande Jul 27 '13 at 10:09

1 Answers1

0

Cross Domain Request with Ajax are fobidden cause of Same Origin Policy: http://en.wikipedia.org/wiki/Same_origin_policy

So what are you alternatives?

  1. Learn to use AJAX with JSONP - will only work if the other side provides it
  2. Write a PHP bridge running locally that provides the remote data for you
  3. Use postMessage: https://developer.mozilla.org/en-US/docs/Web/API/window.postMessage
Henry Ruhs
  • 1,533
  • 1
  • 20
  • 32