jQuery Issue

Discussion in 'jQuery' started by cancer10, Jul 11, 2008.

  1. #1
    Hi jQuery Gurus,

    This is a very interesting question.

    I have a drop down box and a button on page1.php

    Clicking on that button adds whatever it is in the dropdown in the database.

    I am using the following jQuery on page1.php


    
    <script>
    $(document).ready(function(){
    
    
    
    	$("#add").click(function(){
    	$(".status").html("Adding. Please Wait...").show("slow");
    		$.get("page2.php",{txtDropDown:$("#txtDropDown").val(),action:'add'},function(data){$("#quote").html(data);$(".status").html("Added Successfully.").hide("slow");})
    		return false;
    	});//Submit function
    	
    	
    
    
    
    
    });//Ready function	
    
    </script>
    
    Code (markup):
    - The .status div will show the current status. Like data added, data deleted, data updated successfully messages
    - The #quote div will display the added items.
    - Page2.php is doing all the processing.



    Now I have managed to program page2.php that it will not add one data more then once, How do I now display a message in the .status div that the item is already added in the database and that u cannot add the same item again?



    Thanx
     
    cancer10, Jul 11, 2008 IP
  2. Panzer

    Panzer Active Member

    Messages:
    381
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    58
    #2
    You can do the traditional $i++ method, and then seeing if $i is greater than 1 - to count how many times the AJAX has been sent.
     
    Panzer, Jul 15, 2008 IP