The judgment about Ajax

Source: Internet
Author: User
The next paragraph is to determine if there is an AJAX request
But it's really hard to understand
Can you comment
Determine if there is an AJAX request $act =!empty ($_get[' act ')? $_get[' act ': '; if ($act = = ' Cat_rec ') {    $rec _array = Array (1 = ' best ', 2 = ' new ', 3 = ' hot ');    $rec _type =!empty ($_request[' Rec_type ')? Intval ($_request[' Rec_type '): ' 1 ';    $cat _id =!empty ($_request[' cid ")? Intval ($_request[' CID '): ' 0 ';    Include_once (' includes/cls_json.php ');    $json = new json;    $result   = Array (' ERROR ' = 0, ' content ' = ', ' type ' = ' = ' $rec _type, ' cat_id ' + $cat _id);    $children = Get_children ($cat _id);    $smarty->assign ($rec _array[$rec _type]. ' _goods ',      get_category_recommend_goods ($rec _array[$rec _type], $children));    Recommended Products    $smarty->assign (' cat_rec_sign ', 1);    $result [' content '] = $smarty->fetch (' Library/recommend_ '. $rec _array[$rec _type]. '. LBi ');    Die ($json->encode ($result));}


Reply to discussion (solution)

Strictly speaking, this decision is to detect whether a GET request is being requested. is to get the get parameters and then judge what is not understood.

I don't know where you are, or you're not sure. This is a simple HTTP GET access output corresponding data based on the information obtained.

To determine if there is a GET request, and get the act value in the request parameter, it is not always possible for the AJAX call to   be a normal browser call $act =!empty ($_get[' act '])? $_get[' act ']: ";// If the GET request parameter Act is CAT_REC, execute the IF code, if not equal, omit if ($act = = ' Cat_rec ') {    $rec _array = Array (1 = ' best ', 2 = ' new ', 3 =& Gt ' hot ');    $rec _type =!empty ($_request[' Rec_type ')? Intval ($_request[' Rec_type '): ' 1 ';    $cat _id =!empty ($_request[' cid ")? Intval ($_request[' CID '): ' 0 ';    Include_once (' includes/cls_json.php ');    $json = new json;    $result   = Array (' ERROR ' = 0, ' content ' = ', ' type ' = ' = ' $rec _type, ' cat_id ' + $cat _id);     $children = Get_children ($cat _id);    $smarty->assign ($rec _array[$rec _type]. ' _goods ',      get_category_recommend_goods ($rec _array[$rec _type], $children));    Recommended Products    $smarty->assign (' cat_rec_sign ', 1);    $result [' content '] = $smarty->fetch (' Library/recommend_ '. $rec _array[$rec _type]. '. LBi ');    Die ($json->encode ($result));}

You hurt my heart ah, in fact, I understand, but, you are wrong, dare me to say the answer, probably a lot of people will say, this still use to say, certainly ha, this is human! So I won't tell you the answer.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.