Jump to content

Submit Form Without Going to ACTION page?


limitphp

Recommended Posts

I use ajax on my main page.  When a user clicks on "Add to Playlist" it calls an ajax function which makes a little box drop down underneath the "Add to Playlist" link.

The box comes from the php page the ajax calls (add_playlist.php) 

 

Inside the box a user can click an "Add" button which is part of a form. 

 

What I want to happen, is when the user clicks "Add", I want it to submit the form and add the song to the playlist without leaving the main page.

 

Unfortunately, what happens right now is, it leaves the main page and goes to the ajax page. 

 

There's probably a different way to go about what I want, i just don't know what it is.  I'm still new to this stuff.

 

 

 

Link to comment
Share on other sites

<form action="blah" method="blah" onsubmit="return SomeFunction(this);">
</form>

 

If SomeFunction returns false, the form will not submit.

 

blah and blah would be used if onsubmit returned true.

 

 

Or do you have a question about the actual AJAX parts?

Link to comment
Share on other sites

<form action="blah" method="blah" onsubmit="return SomeFunction(this);">
</form>

 

If SomeFunction returns false, the form will not submit.

 

blah and blah would be used if onsubmit returned true.

 

 

Or do you have a question about the actual AJAX parts?

 

I'm not sure.  What I want is, on the main page, when a user clicks "Add to Playlist" a box will come up that has some checkboxes with their existing playlists and a textbox where they can add a new one and an Add button.  Once they select the playlists to add the song to, or type in a new one in the text box, they'll hit the Add button.  What I want to happen then, is for the box to say Song has been added to playlist.  And then they can click on an (x) or something where they can close the box.  All the while the main page will stay open and not change.

 

Right now, I use Ajax to open the box.  What I think I'm going to have to do is use ajax again on the page that contains the box, that way when they click the Add button, it'll use ajax to add the song to the playlist, all while keeping the main page open.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.