0

I am making a mozilla extension, to notify me when an event happen in a specific web page, the problem is that I am doing a POST request using jquery, but it doesn't work.

here is that part of the code (I use it in content.js)

var xhrt = $.post( "https://api.pushed.co/1/push", function( dataToPush ) {
  alert( "success" );
},


)
  .done(function() {
    alert( "second success" );
  })
  .fail(function(xhr, textStatus, error) {
    alert( "error2" );
    console.log(error+"")
  })
BadrEddineBen
  • 235
  • 1
  • 4
  • 24
  • Please provide details concering *but it doesn't work* – Taplar Apr 24 '18 at 16:46
  • @Taplar it fires an error, please read my updated code – BadrEddineBen Apr 24 '18 at 16:49
  • And what information can you gather from the request in the network tab and console regarding the response code, any response data, etc? – Taplar Apr 24 '18 at 16:51
  • @Taplar all I am getting is textStatus:"error" and in the network tab, there is nothing abt that request, I think that the request is blocked coz it is a cross domain request, what do you think ? – BadrEddineBen Apr 24 '18 at 16:54
  • Look in the network tab before you make the ajax request, and then case the ajax request to happen. You will see it show up in there and it should result in some code. Since it is coming back with an error it should be some non-200 non-300 response code. – Taplar Apr 24 '18 at 16:55
  • It is still the same after the request, it doesnt change – BadrEddineBen Apr 24 '18 at 16:58
  • So no code shows up? The page that you are viewing at the time that this ajax runs, is the page running on `https://api.pushed.co`? A non-code could indicate you are hitting a CORS error by trying to hit a different domain than the page you are viewing. – Taplar Apr 24 '18 at 17:00
  • I tried it manualy using the console, and it gave me a security error, "the page's setting blocked the loading of a resource at http..." – BadrEddineBen Apr 24 '18 at 17:05
  • Possibly related: https://stackoverflow.com/questions/37298608/content-security-policy-the-pages-settings-blocked-the-loading-of-a-resource – Taplar Apr 24 '18 at 17:07
  • Thank you so much @Taplar I found the code responsible for that, seems that they have this "" in their web page, I am gonna remove it using jquery – BadrEddineBen Apr 24 '18 at 17:17
  • Good deal. Hope that helps. – Taplar Apr 24 '18 at 17:26
  • Yeah it really helped, God bless ! – BadrEddineBen Apr 24 '18 at 17:26

0 Answers0