Call some php code on another domain

Hi,
I dont know if this is even possible (because of security), but thought Id ask the question.

I have 2 websites. On ‘website 1’ I have a simple jquery function:

$("#sendMessageButton").click(function(){
  $.ajax({
  url: '//www.website2.com/process_email.php',
  success: function(data) {
    alert('email sent');
  }
});
});

On ‘website 2’ I want to execute some php. Is this even possible?
Thanks

Yes, but I’m sure you’ll run into cross-site issues. I think the term to search for is CSRF.

Actually I think @bolton wants to search for CORS (Cross-Origin Resource Sharing), not Cross-Site Request Forgery :slight_smile: This MDN page has some info about how to do this, with a PHP snippet to help.

1 Like

Ah, that would be it. I knew it was some kind of acronym.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.