Call php function from JavaScript

后端 未结 4 606
一个人的身影
一个人的身影 2020-11-21 06:38

Is there a way I can run a php function through a JS function?

something like this:



        
4条回答
  •  灰色年华
    2020-11-21 06:57

    I recently published a jQuery plugin which allows you to make PHP function calls in various ways: https://github.com/Xaxis/jquery.php

    Simple example usage:

    // Both .end() and .data() return data to variables
    var strLenA = P.strlen('some string').end();
    var strLenB = P.strlen('another string').end();
    var totalStrLen = strLenA + strLenB;
    console.log( totalStrLen ); // 25
    
    // .data Returns data in an array
    var data1 = P.crypt("Some Crypt String").data();
    console.log( data1 ); // ["$1$Tk1b01rk$shTKSqDslatUSRV3WdlnI/"]
    

提交回复
热议问题