Jquery ui dialog-window

Hello experts.
I want to use the jquery ui dialog to load a page (ajaxpage.cfm) with a dynamic content every 30 sec.My ajaxpage.cfm has the new records inserted in my db.
there is a query (getlastartikel) and the output of the query.
If getlastartikel.recordcount is 0 (that means that there are no any new records in my db ,i don't want to open the pop up window.
A similar function to this but with xml is here:http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Jquery/Q_25888121.html
(below is a test code that i'm using to show a dialog that call's another page,That what is missing and should be different is instead to click on the link,open automatic the window every 30 sec if a new record exists)
Any help:

<div id="newinserts" title="New Inserts"></div>
<script type="text/javascript">
$(function(){
        // Dialog                       
        $('#newinserts').dialog({
                autoOpen: false,
				bgiframe:true,
				modal:true,
                width: 400,
                height: 240,
				modal: true,
              //  open: function(event, ui) {initialize();}, // this will load google map in the dialog window
                buttons: {
                        "OK": function() { 
						       
                                $(this).dialog("close"); 
                        }, 
                        "Cancel": function() { 
                                $(this).dialog("close"); 
                        } 
                }
        }); 
          // Dialog Link
             $('#dialog_link').click(function(){
               $('#newinserts').dialog('open');
               $('#newinserts').load("../user/ajaxpage.cfm");
                   return false;
                });
 });
</script>

Open in new window

LVL 2
PanosAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

StealthyDevCommented:
can you expose your cfm file to www?

say,

http://www.xyz.com/abc.cfm
PanosAuthor Commented:
Hi again
Do you want me to build an output in html to help you?
StealthyDevCommented:
Hi again.

I need a sample output of "../user/ajaxpage.cfm" as in your example.

OWASP: Threats Fundamentals

Learn the top ten threats that are present in modern web-application development and how to protect your business from them.

PanosAuthor Commented:
OK
wait a moment
PanosAuthor Commented:
see attached code
testcode.txt
StealthyDevCommented:
So here we go !

keep a hidden field in the ajax page (your cfm page).

if it has contents set the hidden field value to the desired value in the script. else, set it to something else or keep it empty..

Cheers



default.html
ajaxpage.html

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PanosAuthor Commented:
Hi.
I did not understand how it works with the hidden field.
I will put in the hidden field the number or records.(the content can be anything,it is a query output)
Now the script must check if the value in the hidden field is >0.

Also i think that it is required an id for the hidden field because i could use a form in the popup window and put there hidden fields too.
StealthyDevCommented:
You can achieve it in any means, since i have used AJAX, as what we built already, i cant access DOM-for hidden field. So, I have made a string search.

If the string is present in the hidden field, the text in the AJAX response should have it.

Just try running the default.html, placeing ajaxpage.html and jquery in a folder.

Regards.
PanosAuthor Commented:
I think i do a mistace.
f.e
if i have 8 records in my ajaxpage   how would be the value for the hidden field?
do i have to copy and paste the script like it is?

...
if(AjaxHTML.indexOf("#123465789#for-telling-page-has-contents###") > 0)
...
StealthyDevCommented:
Hmm, this is simple,

The only problem we face is, we should not show the dialog if there are no items to display.

For this, i am checking the hidden field.

You need to put "#123465789#for-telling-page-has-contents###" in the hidden field if you want to display the alert. Else leave it empty. :)

Also, make sure that "#123465789#for-telling-page-has-contents###" will not come in your message. So give it as lengthy and non-occurring.

Regards.

PanosAuthor Commented:
Now i understand.
I could simple set a value "norecords" for  recordcount 0
and use in the script:
if(AjaxHTML.indexOf("norecords")  > 0)

???
StealthyDevCommented:
No, if you have norecords as a text in your message, it would cause the messagebox to not to be displayed. (i am telling this due to experience)

So, try to give a strong value.

ie,. norecords = #123465789#for-telling-page-has-contents###


PanosAuthor Commented:
OK senthurpandian.
All the comments where very helpful for me.
(by the way: this is working for me #norecords# but i will use your code to be shure!! that it will work.

Thanks alot
PanosAuthor Commented:
Thank you very much for your help.
A next question will come for the position of the popup window.
I want to place it to the bottom right corner.
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Jquery/Q_25907322.html?fromWizard=true
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming Theory

From novice to tech pro — start learning today.