Specifically for web applications.
AJAX can't access a different server to get the value.
So what JS file do I embed to use the API for web applications?


Offline
cocolover76 wrote:
Specifically for web applications.
AJAX can't access a different server to get the value.
So what JS file do I embed to use the API for web applications?
PHP can fetch values using file_get_contents('http://') etc.
For JS, AJAX can get data from other servers, can't it?
Offline
LS97 wrote:
cocolover76 wrote:
Specifically for web applications.
AJAX can't access a different server to get the value.
So what JS file do I embed to use the API for web applications?PHP can fetch values using file_get_contents('http://') etc.
For JS, AJAX can get data from other servers, can't it?
No, AJAX can't. I tried that once to use a Dropbox HTML page to display HTML from TXT files on my Sharkserve to avoid ads AND Dropbox limits. And also, what is the URL???
Last edited by cocolover76 (2012-02-20 15:31:28)


Offline
cocolover76 wrote:
LS97 wrote:
cocolover76 wrote:
Specifically for web applications.
AJAX can't access a different server to get the value.
So what JS file do I embed to use the API for web applications?PHP can fetch values using file_get_contents('http://') etc.
For JS, AJAX can get data from other servers, can't it?No, AJAX can't. I tried that once to use a Dropbox HTML page to display HTML from TXT files on my Sharkserve to avoid ads AND Dropbox limits. And also, what is the URL???
did you try http://www.ajax-cross-domain.com/? It sounds good.
The URL depends on the data you want...
Offline
LS97 wrote:
cocolover76 wrote:
LS97 wrote:
PHP can fetch values using file_get_contents('http://') etc.
For JS, AJAX can get data from other servers, can't it?No, AJAX can't. I tried that once to use a Dropbox HTML page to display HTML from TXT files on my Sharkserve to avoid ads AND Dropbox limits. And also, what is the URL???
did you try http://www.ajax-cross-domain.com/? It sounds good.
The URL depends on the data you want...
I'm looking for particularly the auth one, but is there like a list of all of the APIs?


Offline
cocolover76 wrote:
LS97 wrote:
cocolover76 wrote:
No, AJAX can't. I tried that once to use a Dropbox HTML page to display HTML from TXT files on my Sharkserve to avoid ads AND Dropbox limits. And also, what is the URL???did you try http://www.ajax-cross-domain.com/? It sounds good.
The URL depends on the data you want...I'm looking for particularly the auth one, but is there like a list of all of the APIs?
Sci is working on that ^^
Offline
veggieman001 wrote:
cocolover76 wrote:
LS97 wrote:
did you try http://www.ajax-cross-domain.com/? It sounds good.
The URL depends on the data you want...I'm looking for particularly the auth one, but is there like a list of all of the APIs?
Sci is working on that ^^
Where is the work in progress?
(PDF, Word, HTML, or Text, or I won't accept)


Offline
cocolover76 wrote:
veggieman001 wrote:
cocolover76 wrote:
I'm looking for particularly the auth one, but is there like a list of all of the APIs?Sci is working on that ^^
Where is the work in progress?
(PDF, Word, HTML, or Text, or I won't accept)
He hasn't finished it yet and hasn't released a work in progress. Jeez, be patient.
Offline
There's a page on SVN that documents it though... I didn't bookmark it so I can't find it for you sorry
Offline
LS97 wrote:
There's a page on SVN that documents it though... I didn't bookmark it so I can't find it for you sorry
![]()
Oh... this?
Offline
cocolover76 wrote:
LS97 wrote:
cocolover76 wrote:
No, AJAX can't. I tried that once to use a Dropbox HTML page to display HTML from TXT files on my Sharkserve to avoid ads AND Dropbox limits. And also, what is the URL???
did you try http://www.ajax-cross-domain.com/? It sounds good.
The URL depends on the data you want...I'm looking for particularly the auth one, but is there like a list of all of the APIs?
The actual source file veggieman001 posted is the best source, but I went through and deleted all the code a while ago, leaving the comments and signatures intact. It may be outdated now, but if you want you can see it here.
Offline
Actually, you can use regular AJAX with a different server. It won't work in userscript, and you have to write your own functions. I wouldn't recomend it, though, because the browser asks the client if they want to allow the connection, so I would use php to get the info.
Offline
GP1 wrote:
Actually, you can use regular AJAX with a different server. It won't work in userscript, and you have to write your own functions. I wouldn't recomend it, though, because the browser asks the client if they want to allow the connection, so I would use php to get the info.
How about the php gets the data and you use Ajax to get the data from the PHP?
Offline
SJRCS_011 wrote:
GP1 wrote:
Actually, you can use regular AJAX with a different server. It won't work in userscript, and you have to write your own functions. I wouldn't recomend it, though, because the browser asks the client if they want to allow the connection, so I would use php to get the info.
How about the php gets the data and you use Ajax to get the data from the PHP?
Yes, that works, and it's exactly what I'd thought of in the first place
Offline
cocolover76 wrote:
Specifically for web applications.
AJAX can't access a different server to get the value.
So what JS file do I embed to use the API for web applications?
Woot ? It cant ???..
HTTP access control from x-domain
since in earlier days of web XHR was starting to go used to do a lot of illegal fetching of data from sites so w3c specified a new header for XHR which must be sent via server side
in order to allow MODERN browsers to fetch AJAX
an API must have this
Access-Control-Allow-Origin: <origin> | *
In order to allow cross domain ajax so maybe the API you are using is an internal api and not for public use..
Okay here is your workaround for fetching information and writing a PHP proxy
<?php
$base = 'http://scratch.mit.edu';
function failOut($http, $text) {
header('HTTP/1.x ' . $http);
die(htmlspecialchars($text));
}
$context = stream_context_create(
array(
'http' => array(
// this should not be required, grrrr!
'user_agent' => "GET / HTTP/1.0\r\n"
."Host:117.200.149.48\r\n" // Replace with server IP
."User-Agent: Mozilla/5.0 (compatible; ShoutCastInfoClass/0.0.2; ".PHP_OS.")\r\n"
."\r\n",
),
)
);
$content = file_get_contents($base, false, $context)or die("UnABLE TO lOaD");
echo $content;
?>The stream context is required since new web servers wont detect it as an HTTP request unless you send the proper headers and so if u just post a request like that
you probably will fall with nothing output
oh and as a tip to all javascripters
Google Chrome Console and Mozzilla Firefox Firebug are two of your best friends learn them they basically show you errors and etc when your code is wrong or when you use a method that has been deprecated ^^ ,
Last edited by fanofcena (2012-02-21 08:10:48)
Offline
fanofcena wrote:
do i always kill the topics ?
Maybe because you answer them so well.
Offline