snipt

Ctrl+h for KB shortcuts

JavaScript

Get client IP through jquery

1
2
3
$.getJSON("http://jsonip.appspot.com?callback=?",function(data){
    alert( "Your ip: " + data.ip);
});
https://snipt.net/embed/6bb20bf4f8b9960678f2023d72770ba1/
/raw/6bb20bf4f8b9960678f2023d72770ba1/
6bb20bf4f8b9960678f2023d72770ba1
js
JavaScript
3
2019-07-12T05:05:43
True
False
False
/api/public/snipt/12079/
get-client-ip-through-jquery
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="nx">$</span><span class="p">.</span><span class="nx">getJSON</span><span class="p">(</span><span class="s2">&quot;http://jsonip.appspot.com?callback=?&quot;</span><span class="p">,</span><span class="kd">function</span><span class="p">(</span><span class="nx">data</span><span class="p">){</span> </span><span id="L-2"><a name="L-2"></a> <span class="nx">alert</span><span class="p">(</span> <span class="s2">&quot;Your ip: &quot;</span> <span class="o">+</span> <span class="nx">data</span><span class="p">.</span><span class="nx">ip</span><span class="p">);</span> </span><span id="L-3"><a name="L-3"></a><span class="p">});</span> </span></pre></div> </td></tr></table>
ip, jquery