I have found this very useful Chrome extension called Postman. This is a very useful extension especially when you are into programming RESTful applications.
One thing I am confused on is that how this plugin/extension able to send POST request successfully on different domains?
I tried voting in a poll using Postman like this.
After submitting that, the vote was actually counted in, but when I tried doing that using AJAX and JavaScript, it fails, because of different origin policy of browsers.
How is that even possible?
Here is my code using jQuery. I used that in my computer though, localhost.
init: function() { $.ajax({ url: 'http://example.com/vote.php', type:'POST', dataType: 'html', data: { id: '1' }, success: function(data) { if ( data == 'voted' ) { $('.set-result').html( 'you already voted. try again after 24 hours' ); } else { $('.set-result').html( 'successfully voted' ); } } }); },
Chrome packaged apps can have cross domain permissions. When you install Postman it promts you that this app will access any domain.
By placing */*
in permissions
section of your manifest file, you can do this.
Read more here: https://developer.chrome.com/extensions/xhr.html
You can add the following header to sent Ajax request in postman.
Content-Type application/json X-Requested-With XMLHttpRequest
Screenshot
Credit to Orion
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With