Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

jQuery.post()

Featured Replies

Hey,

 

Made a similar thread a couple of days ago, but I wasnt sure what was going on.

 

Pretty simple question if anyone can help.

 

Using jQuery's post method, I would like to send some data to a php page, which returns a variable which gets printed back out, obviously without the page refreshing.

 

No real purpose, but if I know how this works I can start to play with it.

 

So here we go:

 

<form class="myform">
<input type="hidden" name="hiddenform" value="some value here" />
<input type="submit" value="submit" />
</form>

 

 

So when that submit button is clicked, it runs this:

 

$.post("test.php", $(".myform").serialize());

 

Okay, now on my test.php page:

 

<?
$thevalue = $_POST['hiddenform'];
?>

 

Now the problem i'm having, is how do I get that variable to appear back on the page with the form? So I can say echo $thevalue;

 

I assume that there needs to be more to the jquery, but the jQuery API isnt so amazing for me.

 

Cheers

jquery post:

 

$.post("test.php", $(".myform").serialize(),function(data){
alert(data);
});

 

php file:

 

$thevalue = $_POST['hiddenform'];
return $thevalue;

that should alert the return value from your php file obviously you can then use the data variable in any way you like it's just an example.

Edited by ysuran

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.