test I would not have to load a new page and do it...">

Running php onClick file

I currently have a php executable:

<a href="test.php?foo=boo">test</a> 

I would not have to load a new page and do it onClick.

Does anyone know an easy way to do this?

I added a more complete example, including the one suggested by ajax. I still have problems getting it to work.

 <script type="text/javascript"> $('li').click(function() { $.ajax({ type: "GET", url: "test.php", data: { foo: 'boo' }, success: function(data){ // use this if you want to process the returned data alert('complete, returned:' + data); }}); }); </script> </head> <body> <div id="header"> <h1>Title</h1> </div> <ul> <li><a href="#">Test</a></li> </ul> </body> </html> 
+4
source share
3 answers

Yes, as your tags say. You will need to use AJAX.

For instance:

 $.ajax({ type: "GET", url: "test.php", data: "foo=boo" }); 

Then you just need to insert this into the click function.

 $('a').click(function() { // The previous function here... }); 

EDIT: GET method changed.

+5
source

you can use jquery and do something like this:

 $.ajax({ url: "test.php", data: { foo: 'boo' }, success: function(data){ // use this if you want to process the returned data // alert('complete, returned:' + data); }}); 

for more information see jquery-documentation

+5
source

In your firl say for example try.html write this code

 <meta http-equiv="refresh" content="2;url=test.php?foo=boo"> 

will it redirect u to test.php? foo = boo after 2 seconds

OR Another way ===========================================

create one php file

 <?php header('Location: test.php?foo=boo'); exit; ?> 

Hope for this help

-4
source

All Articles