www.webdeveloper.com
Results 1 to 3 of 3

Thread: AJAX Issue

  1. #1
    Join Date
    Apr 2009
    Posts
    346

    AJAX Issue

    I'm trying to create a simple AJAX application utilizing jquery-1.5.1 and for some reason it just isn't working.

    This is the javascript function:
    Code:
    <script type="text/javascript" src="jquery-1.5.1.js"></script>
    <script language="javascript" type="text/javascript">
    function viewDetails(cid) {
    	$("#resultDetails").html("Loading...").show();
    	var url="parse_details.php";
    	$.post(url{companyId: cid},function(data){
    	$("#resultDetails").html(data).show();
    	});
    }
    </script>
    Here is the empty div to display the info and below it is the anchor tag that calls the function:
    HTML Code:
    <div id="resultDetails"></div>
    <br />
    <br />
    <a href="#" onClick="return false" onmousedown="javascript:viewDetails('1');">Option 1</a>
    And then in the same directory I have a basic PHP file which I already made sure ran correctly without errors. The problem is when I click on the "Option 1" link, nothing happens.

  2. #2
    Join Date
    Dec 2002
    Location
    St. Louis, MO, USA
    Posts
    1,582
    This is going to sound weird, but put a non-breaking space inside your "resultDetails" div. I've left divs empty, before, and wondered why certain code won't work, then I'll put a &nbsp; inside the div and suddenly it works. Just a suggestion. If that doesn't fix it, maybe someone else can offer advice (I'm not good with AJaX, just yet.)
    |||||
    o . Q
    ___ "You live and you learn; or you don't live long." - Lazarus Long

    ^_^

  3. #3
    Join Date
    Dec 2011
    Location
    Centurion, South Africa
    Posts
    792
    Seems like you were missing a comma in the request:

    Code:
    <script type="text/javascript" src="jquery-1.5.1.js"></script>
    <script language="javascript" type="text/javascript">
    function viewDetails(cid) {
    	$("#resultDetails").html("Loading...").show();
    	var url="parse_details.php";
    	$.post(url,{companyId: cid},function(data){
    	$("#resultDetails").html(data).show();
    	});
    }
    </script>
    Last edited by bionoid; 01-12-2012 at 02:14 PM.
    JavaScript: Learn | Validate | Compact | bionoid

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles