3.2.0

Saving changed grid values

My question is below.

I have an AW.Grid on a page
var obj = new AW.UI.Grid;
which is editable
obj.setCellEditable(true);
each cell change fires the onCellValidated below.

obj.onCellValidated = function(text, column, row){
var r = new AW.HTTP.Request;
r.setURL("http://domain/path/updatesinglecell.php"); // gives error with full path
r.setRequestMethod("POST");
r.setParameter("column", column);
r.setParameter("row", row);
r.setParameter("text", text);
r.request();

r.response = function(data){
alert("row="+row+"; col="+column+"; text="+text+"; sessionid=<?= $sessionid ?>");
// this alert is presented OK if URL is not found
}
}

When a cell change is made the Alert(...) is presented correctly if the URL is not found. If I give the full URL address as
http://domain/path/file.php
then I get an error.

The updatesinglecell.php is
<?php
$column = $HTTP_POST_VARS['column'];
$row = $HTTP_POST_VARS['row'];
$text = $HTTP_POST_VARS['text'];
?>
<html>
<body>
<script>
alert("text=<?= $text ?>");
</script>
</body>
</html>
<?php
?>


I am learning PHP, JavaScript and Active Widgets.
1. Is my code for updatesinglecell.php correct enough to allow me to produce a response like "text=4"? If it were correct I could add other code here to update a database with grid changes.
2. What address should be in the r.setURL(...)? A relative path or the full path?

Any help will be appreciated.

What I am trying to do is save changes to the AW.Grid made by a user into a mySQL database. I need the updatesinglecell.php code to run on each cell validated because in this php file I can save the change to the mySQL database. So far I have been unable to get this php file to run.
Russell Belding
October 23,
OOPS, I should have posted the error message I get to this area.

[Exception... "'Permission denied to call method XMLHttpRequest.open' when calling method: [nsIDOMEventListener::handleEvent]" nsresult: "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)" location: "<unknown>" data: no]
Russell Belding
October 23,
Please ignore my comments about the error in the two posts above, I think I caused it.

My problem is how to get updatesinglecell.php to say something to show it was called.
Russell Belding
October 23,
The error was likely because cross-domain XMLHttpRequest calls are not allowed for security reasons.

The response callback argument contains the returned data, so just return some text from updatesinglecell.php (i.e. echo ...).

r.response = function(data){
alert(data);
}
Alex (ActiveWidgets)
October 23,

This topic is archived.

See also:


Back to support forum