Jump to content

Sorry


atholon

Recommended Posts

I must be stupid because I can`t seem to get what I need from AJAX explanations.

 

I am trying to find a way to make it so that when a user clicks on a "Save" button on a page, the form elements are processed and uploaded to a mysql database. I was told there are two ways to have it done.

 

1. You could have it submit to another page and then have it redirect you back to the form with the data entered automattically.

2. You could use AJAX. (basically that is it).

 

Although I have not seen any AJAX examples that really show how to do that. Can anyone help me?

Link to comment
Share on other sites

Is there a specific reason you want to use Ajax? From what you've explained it just sounds like you need a simple forum that allows users to input information, which is then saved into a database.

If that's correct, you can accomplish it all with one page of PHP. No need for Ajax.

Link to comment
Share on other sites

get option 1 working first, and then if you get that working, then maybe think about option 2.  The reason for that is that option 2 requires you do everything that option 1 requires plus a whole bunch of more stuff. 

 

Like for instance, option 1 requires that you create a server page that will recieve the form field values and then create an sql statement from them that will  then be submitted to the db and stored and if an error occurs, return that.  Guess what? Option 2 requires exactly that same thing too, except that to do it through ajax requires that you package the form fields yourself using javascript, then send them through ajax, and probably deal with a number of cross browser javascript/ajax compatability issues.  The server code to process the fields recieved, however, will be nearly identical!

 

If you are a beginner, learn and implement option 1 throughly before you worry about option 2.

Link to comment
Share on other sites

It can stay on the same page. All it has to do is have the processing direct back to the page it was input on.

And you're right, you can't do file uploads with Ajax EXCLUSIVELY, but you can use Ajax in conjunction with PHP to do an upload while still having things like progress bars, although PHP does all that on it's own without Ajax.

Link to comment
Share on other sites

hmmm.. I am looking for one that doesn`t do the clicking and take a long time in some places... I realize that you can also do <form action="./somepage.php?action=post">

 

But I am looking for a sleaker look. If I wanted to I could do that when uploading files and use AJAX for the other stuff...you think that would work?

 

I swear I have seen other sites like myspace that somehow uploaded without refreshing the page.

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.