You can easily do it without Request.HTML and it will solve the <br />
getting to <br>, which is not a bug or problem, in my opinion.
And IMHO you shouldnt create a new Request everytime you call this function.
And do you really need this check for the XMLHttpRequest Object? I mean, who
uses a browser that dont have it? But anyway....
The code would look like this:
var req = new Request({url:'submitSub.php',
onSuccess: function(responseHtml) {
//Inject the new DOM elements into the results div.
$('sub_list').set('html', responseHtml);
},
//Our request will most likely succeed, but just in case,
we'll add
an
//onFailure method which will let the user know what
happened.
onFailure: function() {
$('sub_list').set('text', 'The request failed.');
}
});
function sendSubtitle(){
if(!window.XMLHttpRequest && !window.ActiveXObject){ //
XMLHttpRequest non supporté par le navigateur
alert("Votre navigateur ne supporte pas les objets
XMLHTTPRequest...");
return;
}
var JSONsub = JSON.encode(sstitres);
req.send('&sstitres='+JSONsub);
}
Fábio Miranda Costa
Engenheiro de Computação
http://meiocodigo.com
On Mon, Jun 15, 2009 at 6:18 PM, vikti <[email protected]> wrote:
>
> Hi,
>
> I wrote this code :
>
> function sendSubtitle()
> {
> var JSONsub = JSON.encode(sstitres);
> var req = null;
>
> if(!window.XMLHttpRequest && !window.ActiveXObject){ //
> XMLHttpRequest non supporté par le navigateur
> alert("Votre navigateur ne supporte pas les objets
> XMLHTTPRequest...");
> return;
> }
>
> req = new Request.HTML({url:'submitSub.php',
> onSuccess: function(html) {
> //Clear the text currently inside the results div.
> $('sub_list').set('text', '');
> //Inject the new DOM elements into the results div.
> $('sub_list').adopt(html);
> },
> //Our request will most likely succeed, but just in case,
> we'll add
> an
> //onFailure method which will let the user know what
> happened.
> onFailure: function() {
> $('sub_list').set('text', 'The request failed.');
> }
> });
>
> req.send('&sstitres='+JSONsub);
> }
>
>
> Which inject in a div the code above :
>
>
> <p>0<br>0:00:04:978<br>0:00:08:121<br> A subtitle named FoobaR<br></p>
>
> First question : why all <br /> come to <br> ?
> Second question : the output is the same in IE7 and FF3, but the
> display doesn't work on FF ( there is no return with the <br /> )
> Where am I wrong ?
>
> Are those behaviors known bug ?
>
> Regards,
>