A generic popup for messages?

A generic popup for messages?

I have a multiple page setup where each page is in a different file. I make alot of Ajax calls on each page. Calls that can go wrong. So i need to display some info to the user if it goes wrong. So i thought that popup would be cool. But i need a generic popup that will popup instead of adding popups to every page and file.

In my start.html i have the following:
<body>
        <div data-role="page" id="startpage">
            <div data-role="popup" id="popup_msg" data-theme="a" data-shadow="false" style="min-width:230px;">
                <a href="#" data-rel="back" data-role="button" data-theme="a" data-icon="delete" data-iconpos="notext" class="ui-btn-left">Close</a>
                <p id="startpage_msg" style="text-align:center; padding-top:10px; padding-bottom:10px;"></p>   
            </div>
.....

There is no problem calling it like this:
$("#startpage #popup_msg").popup("open");

But not in another page (file).

Is there a way to do this so i can have ONE popup that will serve all the messages displayed to the user?