03-13-2013, 08:16 AM
I have a page that I click a button - open a popup with a form -process that form and then I close it
I would like to switch it to ajax that it opens the popup - submits and then
with ajax updates that div
what's the best way to do this and does anyone know of any good tutorials explaining htis
03-13-2013, 09:38 PM
Opening a popup and displaying a form: Use the html you are using now.
To submit the form using ajax; I can think of nothing simpler then this http://www.malsup.com/jquery/form/
ajax updates that div What div are you talking about? What info is being used to update it?
03-13-2013, 09:43 PM
the form is saving a picture so I want to be able to update a div of the page that called the popup to show the picture
I do this now with an iframe but I imagine ajax would be much better
03-13-2013, 10:05 PM
ajax really not needed, nor an iframe for that matter. Someone wants to upload an image called "dogface.png". You have that name and should know where your php is going to place it. I'd put it into a folder. When ajax tells you success has happened display the image.
<div id="cf" style="height:100px;width:100px;">
<img id="top" style="width:100%;height:100%;" src="">
</div><br /><br /><button type="button" onclick="showit();">Ajax Success</button>
document.getElementById("top").src = "images/dogface.png"; // PUT YOUR IMAGE HERE
03-13-2013, 10:10 PM
but how do I call showit() after the picture is uploaded?
I don't want to refresh the page - just that div
03-14-2013, 04:05 PM
For calling and passing read this: http://www.w3schools.com/js/js_functions.asp
P.S. Did you run what I gave you? Did the page refresh? Did the div magically show the image? And did the image (Even if larger then the div) fit perfectly?
03-15-2013, 08:13 AM
to page 2
form on page 2 submits to submitpage 2 - from submit page2 I want to refresh a div on page 1
is that possible?
03-15-2013, 08:49 AM
03-15-2013, 08:52 AM
2 submits to submitpage 2 - from submit page2 I want to refresh a div on page 1
is that possible?
03-15-2013, 03:28 PM
@esthera: Sorry my mind reading skills are so bad. No way to know you were putting image on another page without code (Show the importance to paste code here) and your insistence on not refreshing the page thew me.
03-15-2013, 04:42 PM
three words: M. D. N.
or just google whatever it is you're learning: "mdn websockets" or "mdn localstorage" or "mdn a ping" almost always gets the latest info out there and well-written comprehensive documentation, up-to-date compat tables, and relevant examples.
i would not use w3fools for anything, they are outdated in their references, the tutorials demonstrate improper ways of doing things, and then there's all the advertising... yuck.
03-15-2013, 05:49 PM
OK thanks for that rnd me. I shall spend a little more time on this site and see what I think. I do use them.