How is used the 'func' in data parameter of get in jquery ajax?
Ive looked at the example of get in jquery website. The last example show this..
$.get("test.php", { "func": "getNameAndTime" },
function(data){
alert(data.name); // John
console.log(data.time); // 2pm
}, "json");
I was wondering what is the "func" part..how it is used and what you can do with i开发者_运维百科t ?
To me it seem of calling the function getnameAndTime somewhere but where ?
Thanks.
That means in php that the $_GET
param will look like this:
$_GET = array (
'func' => 'getNameAndTime'
)
The second parameter in the $.get
jQuery function is the data you are sending to the script.
To me it seem of calling the function getnameAndTime somewhere but where
It's not explicitly calling the function 'getNameAndTime' but just a query parameter sent back to the server. 'func' is just the param they are looking for and I suspect the server page that they are hitting ('test.php') will know to call a function of that name.
精彩评论