d4h0nk
20 May 2011, 3:15 AM
Hi everyone,
I've a problem. I want to send a Store (what means: the DataRecords) to a php-script. The JS sends just some objects to PHP and I can't deal with it. I ran totally out of coffee and my brain refuses to work anymore.
Can anyone help?
Idea: get the modified records in the store "myAdressStore" and send them via POST to a php-script.
Here is the JS-coding:
sT.on('click', function() {
var params = "store="+myAdressStore.getModifiedRecords();
var request = new XMLHttpRequest();
function setTask() {
if (window.XMLHttpRequestHead) {
request = new XMLHttpRequest();
} else if (window.ActiveXObject) {
try {
request = new ActiveXObject('Msxml2.XMLHTTP');
} catch (e) {
try {
request = new ActiveXObject('Microsoft.XMLHTTP');
} catch (e) {}
}
}
if (!request) {
Ext.Msg.alert(Error', '');
return false;
}
else {
request.open('POST', 'sendtask.php', true);
request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
request.send(params);
request.onreadystatechange = interpretTask;
}
}
function interpretTask() {
switch (request.readyState) {
case 4:
if (request.status != 200) {
Ext.Msg.alert('Error', '');
} else {
var content = request.responseText;
//content = eval("(" + content + ")");
//content = eval('(' + content + ')');
if (!content){
Ext.Msg.alert('Error', '');
}
else
{
for (var i=0; i < content.length; i++){
var dataarray = content[i];
if ( dataarray.rc == '1' ) {
Ext.Msg.alert('Ok', 'Success!');
}
}
}
}
break;
default:
break;
}
}
setTask();
}, this);
Firebug says, I'm sending something like
store=[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
in POST-params. But how to deal with it in PHP? How can I get the records?
I tried to
json_decode($_POST["store"])
but it doesn't work.
Any hints are very welcome!
Thx in advance!
I've a problem. I want to send a Store (what means: the DataRecords) to a php-script. The JS sends just some objects to PHP and I can't deal with it. I ran totally out of coffee and my brain refuses to work anymore.
Can anyone help?
Idea: get the modified records in the store "myAdressStore" and send them via POST to a php-script.
Here is the JS-coding:
sT.on('click', function() {
var params = "store="+myAdressStore.getModifiedRecords();
var request = new XMLHttpRequest();
function setTask() {
if (window.XMLHttpRequestHead) {
request = new XMLHttpRequest();
} else if (window.ActiveXObject) {
try {
request = new ActiveXObject('Msxml2.XMLHTTP');
} catch (e) {
try {
request = new ActiveXObject('Microsoft.XMLHTTP');
} catch (e) {}
}
}
if (!request) {
Ext.Msg.alert(Error', '');
return false;
}
else {
request.open('POST', 'sendtask.php', true);
request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
request.send(params);
request.onreadystatechange = interpretTask;
}
}
function interpretTask() {
switch (request.readyState) {
case 4:
if (request.status != 200) {
Ext.Msg.alert('Error', '');
} else {
var content = request.responseText;
//content = eval("(" + content + ")");
//content = eval('(' + content + ')');
if (!content){
Ext.Msg.alert('Error', '');
}
else
{
for (var i=0; i < content.length; i++){
var dataarray = content[i];
if ( dataarray.rc == '1' ) {
Ext.Msg.alert('Ok', 'Success!');
}
}
}
}
break;
default:
break;
}
}
setTask();
}, this);
Firebug says, I'm sending something like
store=[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
in POST-params. But how to deal with it in PHP? How can I get the records?
I tried to
json_decode($_POST["store"])
but it doesn't work.
Any hints are very welcome!
Thx in advance!