Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
109
rated 0 times [  113] [ 4]  / answers: 1 / hits: 70026  / 11 Years ago, mon, april 15, 2013, 12:00:00

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.



Voting



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' );
}
}
});
},

More From » jquery

 Answers
39

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


[#78889] Sunday, April 14, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
devinjadong

Total Points: 711
Total Questions: 117
Total Answers: 100

Location: Andorra
Member since Sat, May 27, 2023
1 Year ago
devinjadong questions
Thu, Feb 17, 22, 00:00, 2 Years ago
Wed, Dec 8, 21, 00:00, 2 Years ago
Tue, Oct 27, 20, 00:00, 4 Years ago
Fri, Oct 18, 19, 00:00, 5 Years ago
;