CodeIgniter Forums
ajax jquery multiple button only first work rest don please help - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: ajax jquery multiple button only first work rest don please help (/showthread.php?tid=45517)



ajax jquery multiple button only first work rest don please help - El Forum - 09-24-2011

[eluser]adityajoshi[/eluser]
html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Sign Up!</title>
<link rel="stylesheet" href="http://localhost/ci_series/css/style.css" type="text/css" media="screen" />
[removed][removed]

</head>
<body>
<div id = "posts">
Badminton
</div>

<div id = "comments">
I am at dr bombays
</div>
<div id = "comments">
is aj
aj is
</div>
<h1>Contact Us!</h1>
<div id="contact_form">
&lt;form action="http://localhost/ci_series/index.php/contact/submit" method="post"&gt;
&lt;input type="hidden" name="entry_id" value="1" /&gt;
&lt;input type='text' name='name' value='Name' id='name'/&gt;&lt;input type="submit" name="submit" value="Submit" id="submit" />&lt;/form&gt; </div>
<div id="main_content">
</div>
<hr >

<div id = "posts">
Badminton
</div>

<div id = "comments">
I am at dr bombays
</div>
<div id = "comments">
is aj
aj is
</div>
<h1>Contact Us!</h1>
<div id="contact_form">
&lt;form action="http://localhost/ci_series/index.php/contact/submit" method="post"&gt;
&lt;input type="hidden" name="entry_id" value="1" /&gt;
&lt;input type='text' name='name' value='Name' id='2'/&gt;&lt;input type="submit" name="submit" value="Submit" id="submit" />&lt;/form&gt; </div>
<div id="main_content">
</div>
<hr >

[removed]
$('#submit').click(function() {

var name = $('#name').val();

if (!name || name == 'Name') {
alert('Please enter your name');
return false;
}

var form_data = {
name: $('#name').val(),
email: $('#entry_id').val(),

ajax: '1'
};

$.ajax({
url: "http://localhost/ci_series/index.php/contact/submit",
type: 'POST',
data: form_data,
success: function(msg) {
$('#main_content').html(msg);
}
});

return false;
});


[removed]


&lt;/body&gt;

&lt;/html&gt;

the problem is that only first submit button work in ajax rest don't they refresh the page