?
Solved

Need to refresh/reload a div after form submission

Posted on 2012-04-12
5
Medium Priority
?
1,371 Views
Last Modified: 2012-04-16
Hi,

I thought this was a extremely simple question, but ik can't find the answer...
After my php form is submitted, it echoes: "form submitted"

When this message shows, i would a specific div to de reloaded / refreshed. because it contains a picture that could be renewed by the form.

How can i make this specific div refresh?

Thanks
0
Comment
Question by:peps03
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 37838476
>After my php form is submitted, it echoes: "form submitted"

what about :

After my php form is submitted, it echoes: "form submitted<div style='display:none'><img src='images/'" . $img_fullpath . "' /></div>"

echo "form submitted<div id='myimage' style='display:none'><img src='images/'" . $img_fullpath . "' /></div>";

Open in new window


to show it :

to refresh your div :

document.getElementById("your_div_ID").innerHTML = document.getElementById("myimage").innerHTML;

Open in new window

0
 
LVL 20

Expert Comment

by:Proculopsis
ID: 37838482
You need to use an ajax post, as in this jsfiddle.

    $.ajax({
        url: "/echo/html/",
        data: data,
        type: "POST",
        success: success
    });



function success(response) {
    $("#result").text("Form returned: " + response);
}

Open in new window

0
 
LVL 19

Expert Comment

by:Bardobrave
ID: 37838514
Strange... how do you submit your form without losing focus on the page? Do you use an AJAX call to make the submission and load the message when it's returned?

What's the content on the div and how do you load it on the normal flow of the page?
0
 
LVL 8

Expert Comment

by:X-treem
ID: 37838580
if you are using (i)frames you can echo a javascript to change the source of a picture instead of just "form submitted"
if using ajax, you can do this as well, but you need to parse the result (to execute the javascript)
0
 

Author Closing Comment

by:peps03
ID: 37850723
Works great leakim971!!!
Thanks again!
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

741 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question