• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ajax jquery multiple button only first work rest don please help

#1
[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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.