Jquery – SerializeArray()

jQuery SerializeArray() sample code how to send request to your server.

 $.ajax({
    type: "POST",
    url: $(this).attr('action'),
    dataType: "json",
     data     : $(this).serializeArray(),
     success: function(data) {
        if (data.status) { 
		// Success this should redirect or refresh the page. 
		//document.location.reload(true); 
        } else {
		// Error Message 
        }
    },
    error: function(){
              // Error Message 
    }
});

CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource

Here are some issue we encountered when we are using custom font “woff or ttf”.

error-font

Simply go to your .htaccess and add this line.

<IfModule mod_headers.c>
  <FilesMatch "\.(ttf|ttc|otf|eot|woff|font.css|css)$">
    Header set Access-Control-Allow-Origin "*"
  </FilesMatch>
</IfModule>

And make sure when you are saving your .htaccess it has the permission and tried to open and reopen it again just to make sure the the code is added.

jQuery error Access-Control-Allow-Origin when sending post request

We encountered weird error when we are requesting to another domain. Actually it is the same domain but on a sub domain.

Here was the error I encountered

error-oregano
I went to my .htaccess and I add this line of code.

Header add Access-Control-Allow-Origin http://www.domain.com

This will specify the domain you want to allow for security purposes and solve my issue.