Jquery ajax partial no refresh update data implementation case

  • 2020-03-30 01:38:35
  • OfStack

Page to be updated

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <script src="js/jquery.js" type="text/javascript"></script>
    <select id="lucky1" onchange="return duoduo();">
        <option value="1"> The first phase </option>
        <option value="2"> The second phase of the </option>
    <div id="duoduo">
         hello </div>
       <input type="text" id="duo"  />
<script type="text/javascript">
    function duoduo() {
            type: 'post', //Optional get
            url: 'ajax.aspx', //Here is the program that receives the data
            data: 'data=' + $("#lucky1").val(), //Data passed to PHP with multiple arguments connected by &
            dataType: 'html', //The data type returned by the server is optional XML,Json jsonp script HTML text, etc
            success: function(msg) {
                //Here is the data handling function returned by the program after a successful ajax submission. MSG is the returned data, and the dataType is defined in the dataType parameter!
                document.getElementByIdx_x_x("duoduo").innerHTML = msg;
                //$("#duoduo").innerHTML = msg;
            error: function() {
                alert(' I'm sorry. It failed. ');


The operation page

  protected void Page_Load(object sender, EventArgs e)
        if (Request.Params["data"].ToString().Equals("1"))
            Response.Write("<a href="http://www.baidu.com"> The first phase </a>");
        else if (Request.Params["data"].ToString().Equals("2"))
            Response.Write("<a href="http://www.baidu.com"> The first 2 period </a>");

Related articles: