Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery Fails To Read JSON Response From PHP Script
    primarykey
    data
    text
    <p>In my form, I want to do something with two fields:</p> <p>"website_domain" and "website_ip_address"</p> <p>I'm trying to use jQuery/JSON to call a PHP script, pass the website_domain to it, and receive JSON including the IP address of that website. </p> <h2>Problem/Symptoms Description:</h2> <p>It's partially working: On blur, it GETs the url of the PHP script. I can see that much in firebug. I get a 200 OK. Output from the PHP script is valid JSON according to JSONLint:</p> <p>{"field":"website_ip_address","value":"74.125.225.70"}</p> <p>But in Firebug, I don't have a JSON tab. I only have Params and Headers tabs. Not even a Response tab.</p> <p>Needless to say, the website_ip_address field is also not being populated with the data I should be getting from the PHP script's JSON output.</p> <h2>My PHP Script:</h2> <p>It may be important to note that for now, this PHP script on a different domain from my application. Maybe my whole problem is cross-domain?</p> <pre><code>&lt;?php $domain = $_GET["domain_name"]; $ip = gethostbyname($domain); // echo $ip; $json = array( 'field' =&gt; 'website_ip_address', 'value' =&gt; $ip, ); header('Content-Type: text/plain'); echo json_encode($json ); ?&gt; </code></pre> <h2>My jQuery/JSON script:</h2> <p>Note this is written inside a Ruby On Rails application view.</p> <pre><code>:javascript $("#website_domain").bind("blur", function(e){ $.getJSON("http://exampledomain.com/temp_getIP.php?domain_name=" +$("#website_domain").val(), function(data){ $('#website_ip_address').val(data); }); }); </code></pre> <p>I really hope this isn't just a syntax error on my part. I've been writing/rewriting this for 2 days, based on answers I've found on StackOverflow, to no avail. I'm just missing something here.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload