An important reminder to include following header while sending data in Javascript fetch() call in JSON format. Also, do not forget to use JSON.Stringify(). var data = { some_data: ABC}; headers: { ‘Content-Type’: ‘application/json’, }, body: JSON.stringify( data ), This is not needed if you are creating a form data object and appending data to…
Category: Javascript
Decode a PHP encoded string url in Javascript
Sometimes you may face a problem when you have to decode a string with Javascript which was originally url encoded with PHP. This can be an API response or cookie set by PHP setcookie function. A simple way to do this is through decodeURIComponent function in Javascript. But it leaves the "+" signs in the string….