No cache, no wrong version
$. Ajax ({
Type: "Get ",
URL: "index. php ",
Cache: false,
Data: "con = add & act = _ search & Key =" + key + "& id =" + id,
Datatype: "JSON ",
Success: function (MSG ){
Bindgrouplist (MSG );
}
});
// Bind
Function bindgrouplist (result)
{
VaR eles = Document. Forms ['theform']. elements;
Eles ['group _ id']. Length = 1;
For (I = 0; I <result. content. length; I ++)
{
VaR opt = Document. createelement ('option ');
Opt. value = result. content [I]. ID;
Opt. Text = result. content [I]. Name;
Eles ['group _ id']. Options. Add (OPT );
}
}
Cache
$. Getjson ("? Con = add & act = _ search & Key = "+ key +" & id = "+ id, function (data ){
// Bindgrouplist (data)
});
===== PHP make_json_result ======
/**
* Create a data in JSON format
*
* @ Access public
* @ Param string $ content
* @ Param integer $ Error
* @ Param string $ message
* @ Param array $ append
* @ Return void
*/
Function make_json_response ($ content = '', $ error =" 0 ", $ message ='', $ append = array ()){
$ Res = array (
'Error' => $ error,
'Message' => $ message,
'Content' => $ content
);
If (! Empty ($ append )){
Foreach ($ append as $ key => $ Val ){
$ Res [$ key] = $ val;
}
}
$ Val = json_encode ($ res );
Exit ($ Val );
}
/**
*
*
* @ Access public
* @ Param
* @ Return void
*/
Function make_json_result ($ content, $ message = '', $ append = array ()){
Make_json_response ($ content, 0, $ message, $ append );
}
Return make_json_result ($ list );