尊龙凯时人生就是搏

thinkphpͼƬ¿çÓò²»ÏÔʾÎÊÌâÔõÑù½â¾ö

Ê×ÏÈ£¬ÈÃÎÒÃÇÏàʶ¿çÓòÊÇʲô¡ £¿çÓò±¬·¢ÔÚÁ½¸ö²î±ðÓòÃûµÄÍøÕ¾Ö®¼äµ±Ò»¸öÍøÕ¾µÄ×ÊÔ´ÈçJS¡¢CSS¡¢Ajax»òÕßͼƬµÈÇëÇó»á¼ûÁíÒ»¸öÍøÕ¾µÄ×ÊԴʱ£¬ÓÉÓÚͬԴսÂÔµÄÏÞÖƶø±»×èÖ¹¡£ÏÞÖÆÒ»¸öÍøÕ¾Ö»ÄÜ»á¼ûÓëÆä×ÔÉíÓµÓÐÏàͬÓòÃû¡¢Ð­æźͶ˿ڵÄ×ÊÔ´ÊÇͬԴսÂÔµÄÒ»¸öÒªº¦Çå¾²ÌØÕ÷¡£

ÎÒÃÇÔÚÏîÄ¿ÖÐʹÓÃÁËÒ»¸öµÚÈý·½¿âÀ´¼ÓÔØͼƬ£¬¸Ã¿â½ÓÄÉÁ˾ßÓвî±ðÓòÃûµÄµØµãÀ´´æ´¢Í¼Æ¬¡£Òò´Ë£¬ÔÚä¯ÀÀÆ÷ÖУ¬Í¼Æ¬¿çÓòʱÎÞ·¨Õý³£ÏÔʾ¡£

ΪÏàʶ¾öÕâ¸öÎÊÌ⣬ÎÒÃÇÐèÒªÔÚЧÀÍÆ÷¶Ë¾ÙÐÐһЩÉèÖá£×î³£¼ûµÄ½â¾öÒªÁìÊÇÔÚЧÀÍÆ÷¶ËÉèÖÃCORS£¨¿çÔ´×ÊÔ´¹²Ïí£©¡£CORSʹµÃЧÀÍÆ÷¿ÉÒÔÔÚÏìÓ¦¿Í»§¶ËÇëÇóʱ£¬ÏÞÖÆÖ»ÓÐÌض¨µÄÓòÃû¿ÉÒÔ»á¼û¸Ã×ÊÔ´¡£

ÔÚThinkPHP¿ò¼ÜÖУ¬ÎÒÃÇ¿ÉÒÔͨ¹ýÔÚindex.phpÎļþÖÐÌí¼ÓÒÔÏ´úÂëÀ´ÊµÏÖCORS£º

Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡± £»

header('Access-Control-Allow-Origin:*'); //ÔÊÐíËùÓÐȪԴ»á¼û
header('Access-Control-Allow-Method:POST,GET'); //ÔÊÐí»á¼ûµÄ·½·¨

µÇ¼ºó¸´ÖÆ

Õâ¶Î´úÂëÔÊÐíËùÓÐȪԴ»á¼û×ÊÔ´£¬²¢ÇÒÔÊÐíPOSTºÍGET·½·¨µÄ»á¼û¡£

ÔÚÕâÀïҪעÖصÄÊÇ£¬Õâ¶Î´úÂëÓ¦¸Ã·ÅÔÚindex.phpµÄ¶¥²¿£¬ÕâÑùËùÓеÄÇëÇó¶¼ÄÜʹÓøÃÉèÖá£

³ýÁËÉèÖÃCORS£¬ÎÒÃÇ»¹¿ÉÒÔʹÓÃÆäËûÒªÁìÀ´½â¾ö¿çÓòÎÊÌâ¡£ÀýÈçJSONP£¨JSON with Padding£©£¬ËüÊÇÒ»ÖÖ½â¾ö¿çÓòµÄ¿ÉÐÐÒªÁ죬ͨ¹ýÔÚÒ³ÃæÖÐÌí¼ÓÒ»¸öscript±êÇ©£¬½«ÐèÒª»á¼ûµÄÊý¾Ý°ü×°³ÉÒ»¸öº¯Êý£¬È»ºóÔÚÁíÒ»¸öÍøÕ¾ÉÏÎüÊÕ·µ»ØµÄЧ¹û¡£

ÔÚThinkPHP¿ò¼ÜÖУ¬ÎÒÃÇ¿ÉÒÔʹÓÃÈçÏ´úÂëÀ´ÌìÉúJSONPÒªÁ죺

$callback = isset($_GET['callback']) ? $_GET['callback'] : 'callback';
$data = array('name' => 'test', 'age' => 18);
echo $callback . '(' . json_encode($data) . ')';

µÇ¼ºó¸´ÖÆ

ÎÒÃÇÏÈÉó²éGET²ÎÊýÊÇ·ñÓÐcallback²ÎÊý£¬ÈôÓУ¬ÔòÓøòÎÊý×÷Ϊº¯ÊýÃû¡£½Ó×Å£¬½«Ðè·µ»ØµÄÊý¾Ýת»»³ÉJSONÃûÌã¬ÔÙ½«ÆäÌí¼Óµ½»Øµ÷º¯ÊýÖС£×îºó£¬ÔÚ·µ»ØÊý¾Ýʱ£¬ÎÒÃǽ«º¯ÊýºÍÊý¾ÝÒ»Æ𷵻ظøä¯ÀÀÆ÷¡£

ÒÔÉϾÍÊÇthinkphpͼƬ¿çÓò²»ÏÔʾÎÊÌâÔõÑù½â¾öµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是搏ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是搏ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是搏

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ