First of all, mengenai tentang CORS bisa membaca referensinya di sini, bagi yang belum mengenalnya bisa membacanya terlebih dahulu.
Cross-origin resource sharing (CORS) is a mechanism that allows many resources (e.g. fonts, JavaScript, etc.) on a web page to be requested from another domain outside the domain the resource originated from. In particular, JavaScript’s AJAX calls can use the XMLHttpRequest mechanism. Such “cross-domain” requests would otherwise be forbidden by web browsers, per the same origin security policy. CORS defines a way in which the browser and the server can interact to determine whether or not to allow the cross-origin request. It is more useful than only allowing same-origin requests, but it is more secure than simply allowing all such cross-origin requests.
Saat ini saya menghadapi suatu kasus di mana saya melakukan request POST melalui AJAX terhadap domain yang berbeda. Prosesnya seperti ini:
- domainsatu.com melakukan request POST menggunakan AJAX terhadap domaindua.com
- domaindua.com memproses request POST tersebut, lalu memberikan output atau return value terhadap domainsatu.com
- domainsatu.com mendapatkan output atau return value dari domaindua.com.
Continue reading Menelusuri Permasalahan jQuery AJAX CORS (Cross-Origin Resource Sharing)