-
-
Save gasatrya/2c1aff53aeed7b6fb02a8fc25665c1bf to your computer and use it in GitHub Desktop.
Using Fetch with Wordpress Plugins Ajax
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fetch(ajax_url, { | |
method: 'POST', | |
credentials: 'same-origin', | |
headers: new Headers({'Content-Type': 'application/x-www-form-urlencoded'}), | |
body: 'action=zget_profile_user' | |
}) | |
.then((resp) => resp.json()) | |
.then(function(data) { | |
if(data.status == "success"){ | |
_this.setState({loaded:true,user:data.user}); | |
} | |
}) | |
.catch(function(error) { | |
console.log(JSON.stringify(error)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment