jquery json doesn't return any value /repsonse
I'm using the getJSON to get the json value to be returned by a page, but there is no response from the function..
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
alert ("dfdfad");
function sam()
{
alert("entere");
$.getJSON(
'https://test.httpapi.com/api/domains/available.json?',
{
'auth-userid':'234343',
'auth-password':'xxxxxxxx',
'domain-name':'yyyyy',
'tlds':'com',
'tlds':'info',
'suggest-alternative':'true'
},
function(json,textStatus,xhr) {
alert ("inside the fun");
alert("JSON Data: " + json);
}
);
alert("finish");
}
</script>
</head>
<body>
<div>
<h2>Let AJAX change this text</h2>
</div>
<button onclick=sam();>Change Content</button>
</body>
</html>
When i used the following url from the browser it returns the value exactly as json..
The following url may not work from other ip because it needs a registration of ip to get response.. I'm sure that my ip is registered and its working
https://test.httpapi.com/api/domains/available.json?auth-userid=2343432&auth-password=xxxxxx&domain-name=testhiox&tlds=com&tlds=info&tlds=org&suggest-alternative=true
w开发者_Python百科hat may be the issue?
You could use Fiddler to check what the HTTP response to your request is. I attempted using the code below, but got a 504 - Connection Failed error.
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"></script>
<script type="text/javascript">
var samNS = samNS || {};
$(function () {
alert ("dfdfad");
samNS.sam = function ()
{
alert("entere");
$.getJSON(
'https://test.httpapi.com/api/domains/available.json',
{
'auth-userid':'232323',
'auth-password':'xxxx',
'domain-name':'yyyy',
'tlds':'com',
'tlds':'info',
'suggest-alternative':'true'
},
function(json, textStatus, xhr) {
alert ("inside the fun");
alert("JSON Data: " + json);
}
);
alert("finish");
}
});
</script>
</head>
<body>
<div>
<h2>Let AJAX change this text</h2>
</div>
<button onclick="samNS.sam();">Change Content</button>
</body>
</html>
精彩评论