Wednesday, February 25, 2009

[jQuery] Re: jQuery Form Plugin redirects even if I use return false in $('#myForm2').submit(function()

Hi Mike,

Thanks a lot for your reply..

This is what I did exactly....

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://www.odibab.com/ostore/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>';
?>
-----------------------------------------------------------------------------------------------------------------------------


On Feb 25, 11:53 pm, Mike Alsup <mal...@gmail.com> wrote:
> > showRequest doesnt do anything. It just print the returned data.
>
> > Hey one more thing I noted, this plugin works fine with IE but not
> > Mozilla :(
>
> > Any workaround??
>
> I'm afraid you haven't provided enough information.  The plugin works
> fine with both FF and IE so there is something more to the story on
> your end.
>
> Mike

No comments: