Basically i want to send information thats in a textbox to the database.. once sent to the database i want to refresh a different div if you get me so user types.. clicks submit.. info goes database then a div refreshes.. but im unsure on how to do it and what the easyest way is.
Thanks Ash
Send to db then refresh
Send to db then refresh
I would put a signature.. BUT, i don't have the time.
Re: Send to db then refresh
When you say refresh a div, I assume you are talking about making an AJAX request for something than then setting that to the innerHTML attribute of the div.
If so, is the content that you are refreshing just going to make what is sent via the textbox appear ? Because you can just add to the div with JavaScript, no need to refresh it at all.
If so, is the content that you are refreshing just going to make what is sent via the textbox appear ? Because you can just add to the div with JavaScript, no need to refresh it at all.
Re: Send to db then refresh
jacek wrote:When you say refresh a div, I assume you are talking about making an AJAX request for something than then setting that to the innerHTML attribute of the div.
If so, is the content that you are refreshing just going to make what is sent via the textbox appear ? Because you can just add to the div with JavaScript, no need to refresh it at all.
no what it is, is.. in the div will contain data from the database.. basically i am trying to make a shoutbox.. infact i have just had a idea..
div refresh every 1 second via jquery..
send to db via jquery i can do both them just not all in one..
i think i just had a lightbulb appear above my head
![Smile :)](./images/smilies/icon_e_smile.gif)
I would put a signature.. BUT, i don't have the time.
Re: Send to db then refresh
Okay but refreshing a div is not the best use of AJAX, it would be better to only transfer the data (i.e. just the messages) and create the layout with JavaScript. also every 1 second is far too often.
Re: Send to db then refresh
jacek wrote:also every 1 second is far too often.
not really because what if someone posts and it doesnt show for like 5 seconds? they could be like wtf and keep posting until they see it... and as i cant refresh as the message is posted aswell as say every 30 seconds ever 1 second is how its going to have to be until i find out a better solution.
I would put a signature.. BUT, i don't have the time.
Re: Send to db then refresh
Which is why I said you should have the message added to the div when they submit the form, not just relying on the auto updating.