Results 1 to 1 of 1

Thread: Not able to pass Javascript variable into PHP

  1. #1
    Join Date
    Jul 2012
    Posts
    12
    Thanks
    20
    Thanked 0 Times in 0 Posts

    Default Not able to pass Javascript variable into PHP

    I'm new to JS & Ajax. Need urgent help with following code.

    I'm not able to pass Javascript variable into PHP variable. Any help would be much appreciated.

    I've a single file with name a.php which contains entire code (JS+PHP+HTML) and I dont want to use Submit button. Whenever openLightBox() function is called, it should return value to the form called in HTML.


    Code:
    <html>
    <head>
    <script language="JavaScript" type="text/javascript">	
    					
            function openLightBox(imgsrc){
                
    			var id1 = imgsrc;			
    			$.ajax({ 
    				type: "POST",
    				url: "a.php",
    				data: "id1"+id1
    			});
    			
            }
    </head>
    
    <body>
    .
    .
    .
    .
    <form action="#" method="POST" enctype="multipart/form-data">
    <input type="hidden" id="id1" name="id1" />
    
    <?php
        echo "Hello";	
        echo $_POST['id1'];
    	
    ?>
    
    </body>
    </html>
    Thanks in advance!!
    Last edited by jscheuer1; 07-28-2012 at 04:34 AM. Reason: Format

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
  •