I'm having a problem passing POST values from an ExtJS form to my PHP API (located in another domain). Below is the error I've received from firebug
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://172.16.1.35:81/pls/land-title.php. (Reason: missing token 'x-requested-with' in CORS header 'Access-Control-Allow-Headers' from CORS preflight channel).
I've added the CORS header below in the http.conf in my local Xampp server
Header set Access-Control-Allow-Origin "*"
But still no dice...
Below is my sample ExtJS form code
menuOption = Ext.create('Ext.form.Panel', {
autoHeight: true,
width: '100%',
defaults: {
anchor: '100%',
labelWidth: 100
},
items: [{
xtype: 'tabpanel',
width: '100%',
height: '100%',
items: [{
title: 'Title Information',
xtype: 'form',
bodyPadding: 10,
url: 'http://172.16.1.35:81/pls/land-title.php',
layout: 'anchor',
defaults: {
anchor: '100%'
},
defaultType: 'textfield',
items: [{
fieldLabel: 'First Name',
name: 'first',
allowBlank: false
},{
fieldLabel: 'Last Name',
name: 'last',
allowBlank: false
}],
buttons: [{
text: 'Reset',
handler: function() {
this.up('form').getForm().reset();
}
}, {
text: 'Submit',
url: 'http://172.16.1.35:81/pls/test.php',
formBind: true,
disabled: true,
handler: function() {
var form = this.up('form').getForm();
if (form.isValid()) {
form.submit({
success: function(form, action) {
console.log('Success');
},
failure: function(form, action) {
console.log('Failed');
}
});
}
}
}]
}]
}]
});
and below is the PHP I'm passing the values to
<?php
header('Access-Control-Allow-Origin: http://172.16.1.85:8080/ncr/pls/');
if(isset($_REQUEST['first'])) {
echo 'Success: Your firstname is ' . $_REQUEST['first'];
} else {
echo 'ERROR: could not retrieve data';
}
?>