728x90
반응형
In general, Ajax does not work across domains. For instance, a webpage loaded from
## TOC
## AJAX test button
AJAX test button :
```[#pre-code-tistory-comment.linenums.lang-html]
```/
```[#pre-code-code.linenums.lang-html]
```/
## jQuery.get()
```[.scrollable.lang-js]
$.ajax({
type:"GET"
, url:"/rss"
, dataType:"text"
, success:function(resp){
// console.log(resp);
var $result=$("#ajax-get-test-result");
$result.html(m.escapeHTML(resp));
$result.removeClass("prettyprinted");
PR.prettyPrint(function(){}, $result.parent()[0]);
}
});
```/
## RRA
example1.com
is unable to make an Ajax request to example2.com
as it would violate the same origin policy. As a work around, JSONP (JSON with Padding) uses <script>
tags to load files containing arbitrary JavaScript content and JSON, from another domain. More recently browsers have implemented a technology called Cross-Origin Resource Sharing (CORS), that allows Ajax requests to different domains.
- w3schools.com - AJAX
- learn.jquery.com - AJAX; and api.jquery.com - AJAX - jQuery.ajax()
"Unfortunately, different browsers implement the Ajax API differently."
"It offers both a full-featured$.ajax()
method, and simple convenience methods such as$.get()
,$.getScript()
,$.getJSON()
,$.post()
, and$().load()
." - stackoverflow.com - How to start learning Ajax?, 2010-08-21;
Tutorial
728x90
반응형