Forum Moderators: coopster
A page-instance knows what to show (this->dbo->get_content) and can forward the order to change te content on the page (this->dbo->set_content).
It all works like a charm. When a user clicks the save-button on a page, the current page executes this->dbo->set_content and then this->dbo->get_content and the changed data is shown.
However... I would like to use AJAX.
So now i will have my page-object generate this code:
onblur="update_field('var1','var2',var3');"
'update_field' is an ajax function
url = test.php?form=var1&page=var2&field=var3;
xmlHttp.open("GET",url,true);
How do i get this test.php to recognise the current instance of the page-object? I do not want to make a new instance of the class (or do i?). I cannot give the object to the page as a parameter on the url from the ajax function.
Any shov in the right direction is appreciated.
On this index.php i also have the ajax function.
A visitor is on aPage and wants to change some value. He submits aForm.
The website then calls aPage->aDbo->set_values(), followed by Page->aDbo->get_values(). The data now is changed in the database and shown on the form.
With ajax, i want to do the same. However, if i use ajax, i need to provide an address of a page, and not the name of a function. So i provide the url to test.php. Test.php is not aware of the existance of aPage. So it is not possible to use any function of aPage from test.php.
Or is there a way to make this test.php know about aPage?
User is at index.php?page=contact (with htaccess it's gonna be '/contact')
index.php contains 'aPage = new Page(vars);'
test.php is the page on which the action of the ajax function is.
You suggest that i change in my ajax function
url = test.php?form=var1&page=var2&field=var3;
to
url = index.php?form=var1&page=var2&field=var3&page=contact;
and to index.php i add something like 'if($_GET['ajax'] == 'ajax'){$current_page_instance->set_contents($_GET[field_value],$_GET[field]); return;}'
It works (yay!)
Now I think i need to get this part out of my index.php and put it in a 'require_once' file.
Thank you. I will be able to struggle further from here :-) It's hard to change a train of thought that has been running full speed for a couple of years. Working on it though.
Regards