Skip to content

Instantly share code, notes, and snippets.

View zachowdhury's full-sized avatar
🎯
Focusing

zachowdhury zachowdhury

🎯
Focusing
View GitHub Profile
@zachowdhury
zachowdhury / index.html
Created September 6, 2019 12:09
Add Element on form on the fly add element to form exampple // source https://jsbin.com/tavudek
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="add element to form exampple">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Add Element on form on the fly</title>
</head>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css">
body {
background: #f5f5f5;
}
@zachowdhury
zachowdhury / CORS Filter
Created November 15, 2018 13:26 — forked from wildoctopus/CORS Filter
How to fix the CORS issue on backend side , java Springboot App (Handling Simple CORS requests)
//Contents from https://spring.io/understanding/CORS
In the simplest scenario, cross-origin communications starts with a client making a GET, POST, or HEAD request against a resource on the server.
In this scenario, the content type of a POST request is limited to application/x-www-form-urlencoded, multipart/form-data, or text/plain. The request includes an Origin header that indicates the origin of the client code.
The server will consider the request's Origin and either allow or disallow the request. If the server allows the request, then it will respond with the requested resource and an Access-Control-Allow-Origin header in the response. This header will indicate to the client which client origins will be allowed to access the resource. Assuming that the Access-Control-Allow-Origin header matches the request's Origin, the browser will allow the request.
On the other hand, if Access-Control-Allow-Origin is missing in the response or if it doesn't match the request's Origin, the browser will disallow th
// The classic AJAX call - dispatch before the request, and after it comes back
function myThunkActionCreator(someValue) {
return (dispatch, getState) => {
dispatch({type : "REQUEST_STARTED"});
myAjaxLib.post("/someEndpoint", {data : someValue})
.then(
response => dispatch({type : "REQUEST_SUCCEEDED", payload : response}),
error => dispatch({type : "REQUEST_FAILED", error : error})
);
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">