Arduino Ethernet Access-Control-Allow-Origin issues

Hey all i am trying to post data to the arduino ethernet microprocesser but it seems to not work when i try to call the function within my app using Jquery AJAX.

Here is the ajax code:

    function sendToArduinoEthernet(whatsBeingSent) {
		jQuery.support.cors = true;
		
		$.ajax({
			crossDomain: true,
			async : true,
			type: "POST",
			headers: {
				'Access-Control-Allow-Origin': '*'
			},
			url: "http://192.168.9.199:199/?r=" + whatsBeingSent,
			data: '{}',
			contentType: "text/html",
			dataType: "html",
			success: OnSuccessCallArduino,
			error: OnErrorCallArduino
		});		 
	}

And this is the Arduino code:

    #include <Ethernet.h>
    #include <SPI.h>
    
    boolean reading = false;
    char c;
    EthernetClient client;
    String readString = String(30); //string for fetching data from address
    
    ///////////////////////////////////////////////////////////////////////////////////////////
    //Ethernet CONFIGURE
    ///////////////////////////////////////////////////////////////////////////////////////////
      byte ip[] = { 192, 168, 9, 199 };   //Manual setup only 421
      byte gateway[] = { 192, 168, 9, 1 }; //Manual setup only
      byte subnet[] = { 255, 255, 255, 0 }; //Manual setup only
      byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; // if need to change the MAC address (Very Rare)
      EthernetServer server = EthernetServer(199); //port 199
    ///////////////////////////////////////////////////////////////////////////////////////////
    //CONFIGURE for relays
    ///////////////////////////////////////////////////////////////////////////////////////////
      //(analog->digital output)
      int relay1 = 14; //Android phone USB power (turn on to shut off power to phone)
      int relay2 = 15; //Bluray eject
      int relay3 = 16; //PC power button
      int relay4 = 17; //Android Phone Power button
    
    void setup(){
        Serial.begin(9600);
        
        pinMode(relay1, OUTPUT);
        pinMode(relay2, OUTPUT);
        pinMode(relay3, OUTPUT);
        pinMode(relay4, OUTPUT);
        pinMode(fan1, OUTPUT);
        pinMode(fan2, OUTPUT);
        
        analogWrite(fan1, pwmVal);
        analogWrite(fan2, pwmVal);
        digitalWrite(relay1, HIGH);
        digitalWrite(relay2, HIGH);
        digitalWrite(relay3, HIGH);
        digitalWrite(relay4, HIGH);
        
        Ethernet.begin(mac, ip, gateway, subnet); //for manual setup  
        server.begin();
        Serial.println(Ethernet.localIP());
    }
    
    void loop(){
        checkForClient();
    }
    
    void checkForClient(){
        client = server.available();
      
        if (client) {
          boolean currentLineIsBlank = true;
          boolean sentHeader = false;
      
          while (client.connected()) {
              if (client.available()) {  
                  if(!sentHeader){
                    // send a standard http response header
                    client.println("HTTP/1.1 200 OK");
                    client.println("Content-Type: text/html");
                    sentHeader = true;
                  }
        
                  c = client.read();
                  
                  if (readString.length() < 16)
                  {
                    readString += String(c);
                  }
          
                  if(reading && c == ' ') reading = false;
                  if(c == '?') reading = true; //found the ?, begin reading the info 
                  if (c == '\n' && currentLineIsBlank) break;
                
                  if (c == '\n') {
                    currentLineIsBlank = true;          
                  }else if (c != '\r') {
                    currentLineIsBlank = false;
                  }
              }
          }  
          delay(1);   
          switchStuff(readString);
          client.stop();
          readString = "";
          c = ' ';
          reading = false;
        }
    }
    
    void switchStuff(String stuff) {
      stuff.toLowerCase();
      //client.println(stuff);
      
      if (stuff.indexOf("r1on") > 0) {    
        digitalWrite(relay1, LOW); //Turn 5v USB power ON
      } else if (stuff.indexOf("r1off") > 0) {
        digitalWrite(relay1, HIGH); //Turn 5v USB power OFF
      } else if (stuff.indexOf("r2") > 0) {
        digitalWrite(relay2, LOW); //Eject bluray Disc
        delay(500); //pause for 1/2 second
        digitalWrite(relay2, HIGH);
      } else if (stuff.indexOf("r3") > 0) {
        digitalWrite(relay3, LOW); //"Push" the pc power button
        delay(500); //pause for 1/2 second
        digitalWrite(relay3, HIGH); //"Release" the pc power button
      } else if (stuff.indexOf("r4") > 0) {
        digitalWrite(relay4, LOW); //"Push" phone power button down
        delay(7000); //pause for 7 seconds
        digitalWrite(relay4, HIGH); //"Relese" phone power button
      } else if (stuff.indexOf("r5") > 0) {
        digitalWrite(relay4, LOW); //"Push" phone power button down
        delay(500); //pause for 1/2 second
        digitalWrite(relay4, HIGH); //"Relese" phone power button
      }
    }

Is your Ajax client actually making a request to the Arduino?

Is the Arduino receiving an incoming connection, accepting it and receiving the request that the client sent?

Your answer should be based on evidence, not just based on what you expect to happen.

Fixed it by adding this to my arduino code:

                client.println("Access-Control-Allow-Origin: *");