Some of the problems and workarounds that were encountered in order to implement cross-project invocation methods are summarized.
Not much to say, the direct copy of the code to run the first word!
JQ code.
$.ajax ({
Type: "Post",
DataType: "JSON",
URL: "",
Data:null,
Success:function (Result) {
Console.log (result);
},
Error:function () {
}
});
PHP code
$host = "Http://xxxxxx/index.php/Home/index/index";
$ch = Curl_init ($host);
curl_setopt ($ch, Curlopt_header, 0);
curl_setopt ($ch, Curlopt_returntransfer, 1);
curl_setopt ($ch, curlopt_timeout,5);
$arra = curl_exec ($ch);
Var_dump ($arra);
$arra = Json_decode ($arra, true);
$arra = Json_decode (substr ($arra, 3), true); Before using Teamview connected to another computer with a disgusting windows self-brought TXT opened the project file (spit ... hehe). The data will be lost directly afterwards. Normal direct use of Json_decode ($arr) can be
Working with Data
foreach ($recommend as $value) {
$RMD [] = Array_merge ($value, [' PageView ' =>0]);
}
foreach ($rmd as & $value) {
foreach ($arra as $v) {
if ($value [' id '] = = $v [' shop_id ']) {
$value [' pageview '] = $v [' PageView '];
}
}
}
Spit out the data can
PHP Interface Code
Public Function Index ()
{
$arr = Array (' data data ');
Exit (Json_encode ($arr));
}
Run a bit. Well????? Why the backend request to the data, the front end has no data ... wtf
Kiss! Don't worry, first think about what the reason is.
Methods are not found through various methods ...
All right. Link Answer: https://segmentfault.com/q/1010000015934974
Implement PHP Curl invoke methods in different projects