Receive JSON request from PHP -
in firebug, in post tab see following;
json textfieldone "alex" source {"textfieldone :"alex"}
but in params tab see
_dc 1341332451114
in php code when print_r($_request);
get
array ( [_dc] => 1341332451114 )
and not json, found in post tab. how solve ?
i have no clue why hapenning, have tried debug day
update php code:
<?php // make mysql connection mysql_connect("localhost", "root", "pwd") or die(mysql_error()); mysql_select_db("db") or die(mysql_error()); print_r($_request);
in firebug see above responces under url;
post http://localhost/proj/php/result.php?_dc=1341332451114 200 ok 107ms
may know ?_dc=1341366375982
is. sending post
update 2
ext js4 code
model
ext.define ('mycomp.model.myclass',{ extend: 'ext.data.model', fields:['textfieldone'] });
view
ext.define('mycomp.view.user.myclassview', { extend: 'ext.window.window', alias: 'widget.myclassview', initcomponent: function() { this.items = [ { xtype: 'form', items: [ { xtype: 'textfield', name : 'textfieldone', fieldlabel: 'contact person name' } ] } ]; this.buttons = [ { text: 'save', name:'save', action: 'save' } ]; this.callparent(arguments); } });
controller
ext.define('mycomp.controller.myclass',{ extend: 'ext.app.controller', stores:['myclass'], models:['myclass'], views:['myclassview'], init: function(){ this.control({ 'myclassview button[action=save]': { click: this.mymethod } }); }, mymethod: function(button, record) { var win = button.up('window'), form = win.down('form'), values = form.getvalues(), store = this.this.getmyclassstore(), model = store.model, record = model.create(); record.set( values ); store.add( record ); win.close(); store.sync(); } });
store
ext.define('mycomp.store.myclass',{ extend:'ext.data.store', model:'app.model.myclass', proxy: { actionmethods : { create : 'post' }, type: 'ajax', url : '/savetodb.php' } });
i think you'll want set .php file headers serve json:
header('cache-control: no-cache, must-revalidate'); header('expires: mon, 26 jul 1997 05:00:00 gmt'); header('content-type: application/json');
Comments
Post a Comment