Jump to content

Recommended Posts

I have a page with many forms as:

<div class="que_text">1. how ...............ike.</div><div class="que_ans">what<div class="icon tick "><i class="fas fa-check"></i></div>
			    </div>	<footer><form id="aAns1" method="POST" action="">
							<input type="hidden" name="sAction" value="addAns">
							<button class="Add_ans">Add answer</button></form><form id="eAns1" method="POST" action="">
							<input type="hidden" name="sAction" value="editAns">
							<button class="Edit_ans">Edit answer</button></form>
                  			<form id="aQue1" method="POST" action="">
						<input type="hidden" name="sAction" value="editQue">
						
							<button class="nxt_btn Edit_que" id="Edit_que">Edit / Add to Question</button></form>
							
						</footer><div class="que_text">2. John......that she had stolen his friend's money.</div><div class="que_ans">say<div class="icon tick "><i class="fas fa-check"></i></div>
			    </div>	<footer><form id="aAns2" method="POST" action="">
							<input type="hidden" name="sAction" value="addAns">
							<button class="Add_ans">Add answer</button></form><form id="eAns2" method="POST" action="">
							<input type="hidden" name="sAction" value="editAns">
							
							<button class="Edit_ans">Edit answer</button></form>	<form id="aQue2" method="POST" action="">
						<input type="hidden" name="sAction" value="editQue">
							
							<button class="nxt_btn Edit_que" id="Edit_que">Edit / Add to Question</button></form>
							
						</footer>

And i try to post to php as:

	$("button.Add_ans").click(function (e){
		e.preventDefault();
		
        var formData =  $(this).closest('form').serialize();
        
        // Loads the event data from the DB
        	$.ajax({
				type: "POST",
				url:'/Addanswer.php',
				data: formData,
			    dataType: 'json',
			    cache:false,
			    //encode:true,
			success: function(response){
				//console.log(JSON.stringify(response));

				// Alert event data for now
				alert(response);
					});
	                   
				}
			});


    });

My problem is that when i have more than 4 questions the ajax fails to work especially after the 5th question on page. what is wrong here because i xpect to have more than 50 questions

Link to comment
https://forums.phpfreaks.com/topic/322778-ajax-fails/
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.