[jQuery] Re: Calling PHP Functions from jQuery?

2008-07-17 Thread Jean

Very nice!

On Mon, Jul 14, 2008 at 9:00 PM, Kevin Pepperman [EMAIL PROTECTED] wrote:
 I think this plugin does what you are looking for:

 http://plugins.jquery.com/project/EUReCa

 On Mon, Jul 14, 2008 at 10:11 AM, Yavuz Bogazci [EMAIL PROTECTED] wrote:

 Hi,

 is it possible to call php functions from jquery? I knew how to call
 a .php page from jquery with $.post and to echo output or return a
 JSON Object. But my application growth and there is an increase in
 single php pages. This is very confusing and the filemanagement is
 getting complicated.

 How are you solving this problem? Is a good tutorial or info out
 there? I have searched google and couldnt find a useful answer.

 thank a lot
 yavuz



 --
 Yogi Berra  - A nickel ain't worth a dime anymore.



-- 

[]´s Jean
www.suissa.info

 Ethereal Agency
www.etherealagency.com


[jQuery] Re: Calling PHP Functions from jQuery?

2008-07-16 Thread Isaak Malik
Also, file management can be improved drastically by sorting everything in
folders and using namespacing.

I put the AJAX API's in a separate file and if it's getting to big I create
a separate API file for each functionality, for example:
API/API.feedback.php
API/API.updater.php
etc.

On Tue, Jul 15, 2008 at 8:55 PM, Andrew [EMAIL PROTECTED] wrote:


 The really proper way to do this is with XML-RPC or JSON-RPC, which
 is probably what you really want as you're already using JSON.  RPC
 means remote procedure call.  The basics are pretty well illustrated
 on the wikipedia page here:
 http://en.wikipedia.org/wiki/JSON-RPC

 There are a variety of good libraries for doing this in PHP, as well.



 On Jul 14, 7:11 am, Yavuz Bogazci [EMAIL PROTECTED] wrote:
  Hi,
 
  is it possible to call php functions from jquery? I knew how to call
  a .php page from jquery with $.post and to echo output or return a
  JSON Object. But my application growth and there is an increase in
  single php pages. This is very confusing and the filemanagement is
  getting complicated.
 
  How are you solving this problem? Is a good tutorial or info out
  there? I have searched google and couldnt find a useful answer.
 
  thank a lot
  yavuz




-- 
Isaak Malik
Web Developer


[jQuery] Re: Calling PHP Functions from jQuery?

2008-07-15 Thread Abba . Bryant

My recommendation would be to use a serverside framework. I find
CakePHP allows me to simplify ajax development greatly.

On Jul 14, 10:44 pm, Mario Wolff [EMAIL PROTECTED] wrote:
 On 14 Jul., 16:11, Yavuz Bogazci [EMAIL PROTECTED] wrote:

  is it possible to call php functions from jquery?

 My way:
 PHP:
 ?php
 function utf8_encode_recursive($arr){
 array_walk_recursive($arr,create_function('$item,
 $key','$item=utf8_encode($item);'));
 return $arr;
 }
 function utf8_decode_recursive($arr){
 array_walk_recursive($arr,create_function('$item,
 $key','$item=utf8_decode($item);'));
 return $arr;
 }
 if(@$_GET['protocol']!=jsonrpc){
 die(jsonrpc only!);
 }
 if(@$_GET['version']!=1.0){
 die(jsonrpc version mismatch!);
 }
 if(!is_callable('jsonrpc_'[EMAIL PROTECTED]'function'])){
 die(uncallable function!);
 }
 if([EMAIL PROTECTED]'parameter']){
 $_GET['parameter']=array();
 }
 if(!is_array(@$_GET['parameter'])){
 $_GET['parameter']=array($_GET['parameter']);
 }
 echo
 json_encode(utf8_encode_recursive(call_user_func_array('jsonrpc_'.@
 $_GET['function'],utf8_decode_recursive($_GET['parameter'];
 ?

 JS:
 $.getJSON(
 'helper.php',
 { protocol:'jsonrpc',
   version:'1.0',
   'function':'myfunc',
   'parameter[id]':'4711',
   'parameter[value]':'hello world!'
 },
 function(data){
 if(window.console){
 console.log(data);
 }
 }
 );

  thank a lot
  yavuz


[jQuery] Re: Calling PHP Functions from jQuery?

2008-07-15 Thread Andrew

The really proper way to do this is with XML-RPC or JSON-RPC, which
is probably what you really want as you're already using JSON.  RPC
means remote procedure call.  The basics are pretty well illustrated
on the wikipedia page here:
http://en.wikipedia.org/wiki/JSON-RPC

There are a variety of good libraries for doing this in PHP, as well.



On Jul 14, 7:11 am, Yavuz Bogazci [EMAIL PROTECTED] wrote:
 Hi,

 is it possible to call php functions from jquery? I knew how to call
 a .php page from jquery with $.post and to echo output or return a
 JSON Object. But my application growth and there is an increase in
 single php pages. This is very confusing and the filemanagement is
 getting complicated.

 How are you solving this problem? Is a good tutorial or info out
 there? I have searched google and couldnt find a useful answer.

 thank a lot
 yavuz


[jQuery] Re: Calling PHP Functions from jQuery?

2008-07-14 Thread noon

No.  Suggestion: modify your php page to accept a POST/GET variable
specifying the function that you wish to be run...

On Jul 14, 10:11 am, Yavuz Bogazci [EMAIL PROTECTED] wrote:
 Hi,

 is it possible to call php functions from jquery? I knew how to call
 a .php page from jquery with $.post and to echo output or return a
 JSON Object. But my application growth and there is an increase in
 single php pages. This is very confusing and the filemanagement is
 getting complicated.

 How are you solving this problem? Is a good tutorial or info out
 there? I have searched google and couldnt find a useful answer.

 thank a lot
 yavuz


[jQuery] Re: Calling PHP Functions from jQuery?

2008-07-14 Thread Giovanni Battista Lenoci


Yavuz Bogazci ha scritto:

Hi,

is it possible to call php functions from jquery? I knew how to call
a .php page from jquery with $.post and to echo output or return a
JSON Object. But my application growth and there is an increase in
single php pages. This is very confusing and the filemanagement is
getting complicated.

How are you solving this problem? Is a good tutorial or info out
there? I have searched google and couldnt find a useful answer.

thank a lot
yavuz

  


I call a file named ajax.php, passing a parameter for example:

ajax.php?cmd=operators.getlist

In ajax.php I include myajaxfilesdir/operators.getlist.php

and inside myajaxfilesdir/operators.getlist.php

?php
if(basename($_SERVER['SCRIPT_FILENAME']) == 'ajax.php') {
 // i do my stuff here
}
?


--
gianiaz.net - web solutions
p.le bertacchi 66, 23100 sondrio (so) - italy
+39 347 7196482 



[jQuery] Re: Calling PHP Functions from jQuery?

2008-07-14 Thread Iair Salem

I've made something very similar, and I suggest you to try it out,
because it extremely simplifies ajax.
Iair.

On 14 jul, 11:54, Giovanni Battista Lenoci [EMAIL PROTECTED] wrote:
 Yavuz Bogazci ha scritto:

  Hi,

  is it possible to call php functions from jquery? I knew how to call
  a .php page from jquery with $.post and to echo output or return a
  JSON Object. But my application growth and there is an increase in
  single php pages. This is very confusing and the filemanagement is
  getting complicated.

  How are you solving this problem? Is a good tutorial or info out
  there? I have searched google and couldnt find a useful answer.

  thank a lot
  yavuz

 I call a file named ajax.php, passing a parameter for example:

 ajax.php?cmd=operators.getlist

 In ajax.php I include myajaxfilesdir/operators.getlist.php

 and inside myajaxfilesdir/operators.getlist.php

 ?php
 if(basename($_SERVER['SCRIPT_FILENAME']) == 'ajax.php') {
   // i do my stuff here}

 ?

 --
 gianiaz.net - web solutions
 p.le bertacchi 66, 23100 sondrio (so) - italy
 +39 347 7196482


[jQuery] Re: Calling PHP Functions from jQuery?

2008-07-14 Thread Kevin Pepperman
I think this plugin does what you are looking for:

http://plugins.jquery.com/project/EUReCa

On Mon, Jul 14, 2008 at 10:11 AM, Yavuz Bogazci [EMAIL PROTECTED] wrote:


 Hi,

 is it possible to call php functions from jquery? I knew how to call
 a .php page from jquery with $.post and to echo output or return a
 JSON Object. But my application growth and there is an increase in
 single php pages. This is very confusing and the filemanagement is
 getting complicated.

 How are you solving this problem? Is a good tutorial or info out
 there? I have searched google and couldnt find a useful answer.

 thank a lot
 yavuz




-- 
Yogi Berra  - A nickel ain't worth a dime anymore.


[jQuery] Re: Calling PHP Functions from jQuery?

2008-07-14 Thread Mario Wolff

On 14 Jul., 16:11, Yavuz Bogazci [EMAIL PROTECTED] wrote:
 is it possible to call php functions from jquery?

My way:
PHP:
?php
function utf8_encode_recursive($arr){
array_walk_recursive($arr,create_function('$item,
$key','$item=utf8_encode($item);'));
return $arr;
}
function utf8_decode_recursive($arr){
array_walk_recursive($arr,create_function('$item,
$key','$item=utf8_decode($item);'));
return $arr;
}
if(@$_GET['protocol']!=jsonrpc){
die(jsonrpc only!);
}
if(@$_GET['version']!=1.0){
die(jsonrpc version mismatch!);
}
if(!is_callable('jsonrpc_'[EMAIL PROTECTED]'function'])){
die(uncallable function!);
}
if([EMAIL PROTECTED]'parameter']){
$_GET['parameter']=array();
}
if(!is_array(@$_GET['parameter'])){
$_GET['parameter']=array($_GET['parameter']);
}
echo
json_encode(utf8_encode_recursive(call_user_func_array('jsonrpc_'.@
$_GET['function'],utf8_decode_recursive($_GET['parameter'];
?

JS:
$.getJSON(
'helper.php',
{ protocol:'jsonrpc',
  version:'1.0',
  'function':'myfunc',
  'parameter[id]':'4711',
  'parameter[value]':'hello world!'
},
function(data){
if(window.console){
console.log(data);
}
}
);

 thank a lot
 yavuz