Home  >  Article  >  Web Front-end  >  Implementation code for jquery page refresh (partial and full page refresh)_jquery

Implementation code for jquery page refresh (partial and full page refresh)_jquery

WBOY
WBOYOriginal
2016-05-16 18:04:581740browse

Partial refresh:

There are many methods, the common ones are as follows;

$.get method, $.post method, $.getJson method, $.ajax method are as follows

The first two methods of use are basically the same

Copy the code The code is as follows:

$.get(”Default.php”, {id:”1″, page: “2″},
function(data){
//This is the callback method. Return data data. Think here How to deal with it?
});

$.getScript method:
Copy code The code is as follows:

$.getScript("http://jqueryajax.com/jquery.js",
function(){
$("#go") .click(function(){//Callback method
$(”.block”).animate( { backgroundColor: 'pink' }, 1000)
.animate( { backgroundColor: 'blue' }, 1000) ;
});
});

$.getJson just returns a different data type
Copy code The code is as follows:

$.getJson(”Default.php”, {id:”1″, page: “2″},
function(data ){
// Note that the JSON data reference method returned here is "data.info". If you don't understand, you can check the json tutorial. I won't explain too much here
});

$.ajax This method is probably used by many people. But I don't really like using this. Personally, I think the first two are more convenient
Copy code The code is as follows:

$.ajax({
type: “POST”, //Submission type
url: “some.php”, //Submission address
data: “name=John&location=Boston”, //Parameters
success: function(msg){ //Callback method
alert( “Data Saved: ” msg ); //Here is the method content, the same as the get method above
}
});

The following introduces the full page refresh method: sometimes
window.location.reload() may be used to refresh the current page.
parent.location.reload() refreshes the parent object (for frames)
opener.location.reload() refreshes the parent window object (for single window)
top.location.reload() refreshes the top object (for multiple windows)
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn