Forum Moderators: coopster
I've been tying to escape frames and redirect to a new window. I've been employing a javascript like this to open the window up:
<SCRIPT LANGUAGE="JavaScript">
<!--
if (window!= top) top.location.href = location.href;
// -->
</SCRIPT>
The problem is that by doing this a keep conflicting with header ( Location:http://www.example.com)
My question is I know I need AJAX to accomplish what I want but how do I apply this or can someone refer me to a tutorial?
1. Go and get yourself prototype.js from: [prototypejs.org...] (Save it to your web dir under a folder, say, js)
2. Add it into the head of your doc(s): <script type="text/javascript" src="/js/prototype.js"></script>
3. Start playing! You see, AJAX is a HTTPXMLRequest. What it means is that your browser is receiving and sending POST/GET data behind the back. A simple request is as follows:
new Ajax.Request('/some_url',
{
method:'get',
onSuccess: function(transport){
var response = transport.responseText ¦¦ "no response text";
alert("Success! \n\n" + response);
},
onFailure: function(){ alert('Something went wrong...') }
});
It's really simple. If you're wanting to look at adding data into elements, such as DIVs, prototype has added DOM capabilities so that you can select an element (by it's ID) by doing $('ELEMENTSID') and then adding whatever you need to it!
Now I know this is a bit too much to take it, so have a read of: [prototypejs.org...] and take it one step at a time. Have fun!