I'm working on a web site but I have a problem: I have a list of document which if clicked will be shown in an iframe. Over the list and iframe i have an input form in which i must write the document title. So, when i click on a document the first time the input form don't change (it's "#" at default), but when i click on a second document it take the first document's title, and if i continue it take always the last document's title, not the currently selected.
But if I uncommend the alert function, it show the last document's title but the input form show the correct title.
Here the HTML code:
<div>
<iframe class="iframe" src="" id="file" height="480" text-align="center" name="link"> </iframe>
</div>
<div>
Title <br> <input type="text" id="title" value="#" style="background-color:#FFCC99"><br>
</div>
And here jquery/ajax code:
function load(file) {
$.ajax({
method: 'GET',
url: file,
success: function(d) {
$('#file').attr('src',file);
//alert($('#file').contents().find('h1.document-title').text());
$('#title').attr('value',$('#file').contents().find('h1.document-title').text());
},
error: function(a,b,c) {
alert('Non ho potuto caricare il file '+file)
}
});
}
Maybe because alert stop to run code and it allow to load the full document, while without it the value of input form is changed before to full load the selected document?
How I can show the correct tile on the input form? (alert is only for debug,I not need it)
Thank you for your help and sorry for my bad english.