Wednesday, February 25, 2009

[jQuery] jQuery Form Plugin not working in Mozilla 3.0.6!!

Hi,

I just downloaded jquery.form.js from http://malsup.com/jquery/form/#download


The following code works fine in IE (The returned XML from server is
displayed through alert() )
But when I use the same code in Mozilla 3.0.6, It fails. ( I am
getting redirected
to the sell.php5 page )

Can anyone help me please?

Thanks,
Antony Johnson


And here is what I wrote
-------------------------------------------------------------------------------------------------
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="form.js"></script>
<script type="text/javascript">

function processXml(responseXML) {

var message = $('message', responseXML).text();
alert(message);
}


$(document).ready(function() {

var options = {

success: processXml // post-submit callback

};

$('#htmlForm').submit(function() {

$(this).ajaxSubmit(options);

alert('Sending...');

return false;
});

});


</script>
</head>

<body>

<form id="htmlForm" action="http://myserver.com/sell.php5"
method="post">
Message: <input type="text" name="message" value="Hello HTML" />
<input type="submit" value="Echo as HTML" />
</form>

<div id="output2"> </div>
</body>
</html>
----------------------------------------------------------------------------------------------------------------------------
<?php
// !!! IMPORTANT !!! - the server must set the content type to XML
header('Content-type: text/xml');
echo '<root><message>' . $_POST['message'] . '</message></root>';
?>
-----------------------------------------------------------------------------------------------------------------------------

No comments: