41775

how can I get just a single div to refresh on submit as apposed to the entire page?

Question:

I am working with a dynamically generated page written in PHP. The divon the page contain contents listed FancyBox links that open editing screens. Once editing is complete and the user closes the FancyBox modal the changes need to be reflected on the parent page.

Right, so I was able to find a solution that refreshes the entire page on submit using

parent.location.reload (true);

to refresh the entire parent page. But, that causes a browser prompt that is confusing to users and a bit of over kill as I really only need the information edited to refresh.

<strong>how can I get just a single div to refresh on submit as apposed to the entire page??????</strong>

Answer1:

You need to submit the form through AJAX. Since your using something that uses jQuery, you can use it to do it.

<a href="http://net.tutsplus.com/tutorials/javascript-ajax/submit-a-form-without-page-refresh-using-jquery/" rel="nofollow">Here</a> you can find a tutorial on how to do it

Answer2:

I think the best way is loading page fragments with <a href="http://api.jquery.com/load/" rel="nofollow">.load()</a>.

something like,

$('#pageNeedToBeRefreshed').load('test.html #pageNeedToBeRefreshed');

Answer3:

User ,

It should be pretty easy

have a div place holder like below

<div id="dataToRefresh"> </div>

Once you close the dialog, have a event handler...

$('dataToRefresh').html('testing'); // give your data here

it should upate the parts of the page

let me know if you need anything else

please go thruogh .html api for more info

<a href="http://api.jquery.com/html/" rel="nofollow">http://api.jquery.com/html/</a>

Answer4:

Suppose you have the below div to refresh:

Then write

$("#dataToRefresh").load();

Might it will be helping you

Answer5:

Instead of using submit in html you can submit your form using the ajax -

$('#formid').submit(function(){ var data = $(this).serialize(); //this gives you the data of all elements of form in serialized format $.ajax({ type: 'POST', dataType:"json", url: 'your url', data: data, success: function(data){ //replace the contents of the div you want to refresh here. } }); });

Answer6:

jQuery('#id_of_div').load('/url/to/updated/html');

See <a href="http://api.jquery.com/load/" rel="nofollow">jQuery docs for load()</a>

Recommend

  • Splitting a csv file into panda dataframe by multiple columns
  • How to upload video to Vimeo through their api?
  • Why do native C++ projects have a TargetFrameworkVersion?
  • Prevent Emacs from modifying the OS X clipboard?
  • django server code not updating
  • joomla! 1.5.26 and “You are currently logged in to the private area of this site”
  • Weird LEFT OUTER JOIN on Includes eager loading of rails 3
  • formediting modals shows at wrong position
  • How can I make a right-click behave as a left-click for the purpose of selecting or focusing an obje
  • Why is OpenID Connect considered mobile friendly compared to SAML
  • Special chars in Amazon S3 keys?
  • record audio in HTML / js without Flash?
  • Load Same ACF Map Twice on Same Page
  • Timeout a query
  • File loader changed image file name but not the file name in HTML file
  • Is it better to use the “hidden” CSS attribute or fetch each set of new images?
  • Problem with Django using Apache2 (mod_wsgi), Occassionally is “unable to import from module” for no
  • Dart - Isolate Cross Window Communication
  • Repository Browser Only - \"Repository moved permanently to… please relocate”
  • How can I restyle a word when rendering a pdf with pdf.js?
  • what makes a request a new request in asp.net C#
  • Zoom in and out of jPanel
  • Position: fixed nav does not stay fixed
  • Firefox Extension - Monitor refresh and change of tab
  • System.InvalidCastException: Specified cast is not valid
  • Saving Changes After In-App Purchase Has Been Purchased
  • Allowing both email and username for authentication
  • Read a local file using javascript
  • Get one-time binding to work for ng-if
  • How to make a tree having multiple type of nodes and each node can have multiple child nodes in java
  • Spray.io: When (not) to use non-blocking route handling?
  • Apache 2.4 and php-fpm does not trigger apache http basic auth for php pages
  • Sony Xperia Z Tablet not found by adb
  • TFS: Get latest causes slow project reloading
  • Cassandra Data Model
  • To display the title for the current loaction in map in iphone
  • How do you troubleshoot character encoding problems?
  • Codeigniter doesn't let me update entry, because some fields must be unique
  • Django query for large number of relationships
  • How to get NHibernate ISession to cache entity not retrieved by primary key