Jump to content

Sean_Tublewicz

New Members
  • Posts

    6
  • Joined

  • Last visited

Posts posted by Sean_Tublewicz

  1. Hello Requinix. I think I'm getting closer. Now instead of the alert box I just get NULL to show up in the divContainer. 

     

    here is proxy.php:

     

    <?php
    if (!isset($_GET['url']))
    {
    die();
    }
    $url=urldecode($_GET['url']);
    $url='http://' . str_replace('http://','',$url);
    echo file_get_contents($url);
    ?>
     
    and here is my HTML file:
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    <title>TEST PAGE</title>
    <head>
    <script type="text/javascript">
     
    getJSON = function() {
        var resultDiv = $("#resultDivContainer");
        resultDiv.html('Loading...');
        
        var request = {
          version: "0.4", 
    game: "XXXXXXXXX", 
    platform: "XXXXXXXXX", 
    userId: "XXXXXXXXX", 
    password: "XXXXXXXXX",
    data: {}
      };
     
      $('#sendInput').val(JSON.stringify(request));
     
      resultDiv.html(console.log('Sending: ' + $('#sendForm').serialize()));
     
        $.ajax({
            url: "proxy.php?url=XXXXXXXXX",
            type: "POST",
            data: $('#sendForm').serialize(),
            dataType: "json",
            success: function (result) {
            var resultString = JSON.stringify(result); 
            console.log('Result: ' + resultString);
            resultDiv.html(resultString);
            },
            error: function (xhr, ajaxOptions, thrownError) {
            alert(xhr.status);
            alert(thrownError);
            }
        });
    };
     
    </script>
    </head>
    <body>
     
    <h1>Test Page</h1>
     
    <form id="sendForm" action="post"><input id="sendInput" type="hidden" name="json" value="empty" /></form>
     
    <div id="resultDivContainer"></div>
     
    <button type="button" onclick="getJSON()">JSON</button>
     
    </body>
    </html>
     
    As I said it appears to communicate with the servlet... and just enters null into the resultDivContainer and the browser javascript log says sending blah blah blah and result: null. Thanks for the help so far and hopefully with your help I can get this going. 
     
  2. Would it be easier if I can just use PHP for the whole deal? That is fine by me. Unfortunately I can't find many examples that apply to my situation. Does anyone know of any or can you write up a basic one? I don't believe the server is setup to use cURL either. Thanks guys.

  3. I'm sorry if this is in the wrong section. I'm working on coding a page that will pull data from a servlet that's already been coded. Right now I'm just trying to get it to pull and display any information. The developer who coded the servlet says it works on his server and I'd rather not badger him with questions. Any help you can provide would be greatly appreciated. So I am running Wampserver 2.5 a basic installation as I have not changed any settings and my HTML page is as follows: 

     

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    <title>TEST PAGE</title>
    <head>
    <script type="text/javascript">
     
    getJSON = function() {
        var resultDiv = $("#resultDivContainer");
        resultDiv.html('Loading...');
        
        var request = {
          version: "0.4", 
    game: "XXXXXXXXX", 
    platform: "XXXXXXXXX", 
    userId: "XXXXXXXXX", 
    password: "XXXXXXXXX",
    data: {}
      };
     
      $('#sendInput').val(JSON.stringify(request));
     
      resultDiv.html(console.log('Sending: ' + $('#sendForm').serialize()));
     
        $.ajax({
            url: "XXXXXXXXX",
            type: "POST",
            data: $('#sendForm').serialize(),
            dataType: "json",
            success: function (result) {
            var resultString = JSON.stringify(result); 
            console.log('Result: ' + resultString);
            resultDiv.html(resultString);
            },
            error: function (xhr, ajaxOptions, thrownError) {
            alert(xhr.status);
            alert(thrownError);
            }
        });
    };
     
    </script>
    </head>
    <body>
     
    <h1>Test Page</h1>
     
    <form id="sendForm" action="post"><input id="sendInput" type="hidden" name="json" value="empty" /></form>
     
    <div id="resultDivContainer"></div>
     
    <button type="button" onclick="getJSON()">JSON</button>
     
    </body>
    </html>
     
    This is supposed to display some JSON results from a tournament that is ongoing. When I click the JSON button it'll change the resultDivContainer to say "Loading..." and then it gives me a popup that says: "The page at localhost says: 0". Is it because I'm not on the same domain as the servlet? Thoughts? Please and thank you.
×
×
  • Create New...

Important Information

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.