Forum Moderators: open
I am trying to implement an ordering system using AJAX
Top DIV element - List of quotations/orders and status (quotation request in process, awaiting quotation from company, order to be confirmed by user, order confirmed by user, etc...)
Bottom DIV element - Show request/order content (this is where the user can add/modify products or fill forms to add delivery address and date or click button for action).
Example
A/ User click on "send quotation" on the top DIV
B/ Bottom DIV show a form with delivery date and address that user must fill before clicking on "Send"
C/ Bottom DIV show a success message "Your quotation request has been sent. Click here to refresh the top div"
D/ Top div is refreshed and status of the requests/orders modified
You got it... I want to get rid of the "click here to refresh top DIV". I have tried to use an onload event on a DIV element, I have also tried to write javascript in the body <script></script> but both methods failed.
To sum up, once all HTML is output, I need to run a function to refresh another div element automatically and get rid of the <a href="#" onclick="javascript:dosomething(); return false;">Click here to refresh top div</a>
Any suggestions or tips will be appreciated.
Thanks
In fact, I was just about to try this method.
Nonetheless, the problem is that any javascript should be written within the <body></body>
I had tried the following yesterday:
echo "<script>alert('hi')</script>";
and it was not working, therefore I guess that:
echo "<script>setTimeout('dosomething()',3000);</script>";
will also fail.
I will do some more testing today.
In the example example, no alert message unless I click on the link (it is an HTML output in my bottom DIV element using innerHTML)
OK! Your quotation request has been sent to us
<script type="text/javascript">alert('dede');</script>
<a href="#" onclick="javascript:alert('dede');">Click here to refresh top DIV element</a>
Thanks
javascript written to the page via ajax does not execute. there is a hack to get around this but only works in firefox and opera, so not an option
have you tried an iframe? a page called by the iframe src will be able to execute scripts. the limitation here is both pages must be from the same domain for one script to have access to the others function
Yep, you are right...
Javascript written to the page via ajax does not execute so I found a work-around, that is a function to basically load a .js object when calling the ajax page, function which inserts the javascript <script> in the main page using DOM.
Thanks for your help.
Cheers.