klewis
klewis

Reputation: 8389

jquery reloading ajax request

I have a specific situation where a plug-in just will not adjust easily if the browser window is re-sized. So instead of trying to force it to do so, I decided to call the actual plug-in from a ajax post request with jQuery. And that is working out perfectly for me as far as loading it onto my page initially.

But what I want to do is unbind the ajax request, remove the external code from the current page and reload the ajax request to display the plugin content again (at an adjusted screen size, ie. every time a certain $(window).width() is set for 320px, 480px and 800px width screen sizes).

Looking for a basic concept

thanks

Upvotes: 0

Views: 63

Answers (2)

Rohan Kumar
Rohan Kumar

Reputation: 40639

You can use resize function of jquery Like:

$(window).resize(function(){
     // do your code here
});

Docs http://api.jquery.com/resize/

You can also use media in css3 See urls http://www.css3.info/preview/media-queries/ and http://css-tricks.com/css-media-queries/

Read responsive designs here http://webdesignerwall.com/tutorials/responsive-design-with-css3-media-queries

Upvotes: 2

CodeChimp
CodeChimp

Reputation: 8154

Would something like this work?

$(document).ready(function() {
  $(window).resize(function() {
    // Do your ajax call here...
  });
});

Upvotes: 1

Related Questions