SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Mar 2005
    Posts
    276
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Stopping the page refreshing OnClick & Jquery

    Hi.

    I have this bit of code
    Code JavaScript:
     function changeStatus(itemId)
    {
    	$.post("includes/processAccountInformation.php", { itemId: itemId}, 
                  function(data)
    	{ 
                	         alert("Return data" + data); 
            	}); 
                 return false; 
     
    }

    and I use this line to fire it.

    Code HTML:
    <a onclick="changeStatus(45)" href="#">
    <img width="16" height="16" src="images/icons/greenflag.png">
    </a>

    When I click on the link the post request correctly fires but the page refreshes - how can I stop the page refreshing please.

    Thanks
    CHris

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,705
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by chrisio View Post
    When I click on the link the post request correctly fires but the page refreshes - how can I stop the page refreshing please.
    With "return changeStatus(45)" instead.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •