/* * ajax upload * linkage index : When user selects the first drop-down option in index * type : post * used for linkage in index helen English website(http://en.chinatefl.com/) * create by 西兰花的春天(gcx)高 on 2017/1/18. */function ajax_index_Upload( val )
{ var $region = $( "#region" ); var $provinces = $( "#provinces" ); /* Set a parameter, in order to control ajax will not be submitted repeatedly No other operations are performed until a request is completed */ var flag = true; if( flag ) $.ajax( { type: "POST", dataType: "json", url: "/dede/templets/default/china_city.php", async: false, timeout: 1000, data: { "region": val
}, success: function( data )
{ $region.val( data[ 0 ].region ); //set $region’s value = the first of data.region //select $provinces / option $provinces.empty(); //Dynamically generated drop - down list for( var i = 0; i < data.length; i++ )
{ var $option = $( "" ); $provinces.append( $option );
} //get #region and #provinces value get_linkage_val(); flag = false;
}, complete: function( XMLHttpRequest, status )
{ //Timeout, and status is success, error equivalents if( status == 'timeout' )ajaxTimeOut.abort(); //Cancel request }, error: function( XMLHttpRequest, textStatus )
/* * ajax upload (linkage Executes when the page is refreshed) * belong to teaching_in_china web * type : post * used for linkage in teaching_in_china helen English website(http://en.chinatefl.com/) * create by 西兰花的春天(gcx)高 on 2017/1/18. */function ajax_teach_Upload( val1, val2 )
//set $t_region and $t_provinces value if( $region_val && $provinces_val ) //other web into this web { $t_region.val( data[ 0 ].region ); //show index select val in teach_in_china web's linkage $t_provinces.val( $provinces_val );
} else //index into this web { $t_region.val( 'Eastern China' ); //show Default val $t_provinces.val( 'Zhejiang' );