﻿/**
*  Globale Function fuer Ajax
*  name_file         = Name der Datei im ajax Ordner mit Endung  B.z. "ajax_bmi" fuer ajax_bmi.php.
*  phpFunction       = Functionsname in der PHP-Datei als Get wert B.z. "$_GET['phpFunction']".
*  postvars_string   = Uebergabestring der Vars per POST B.z. "name=peter&id=1".
*/
function ajaxPhpCallFunc(name_file, phpFunction, postvars_string, json)
{
    
   var daten = "";
   if( !json ) {
	   var myAjax = new Request(
	                                    {
	                                       url: '/includes/php/ajax/'+name_file+'.php?phpFunction=' + phpFunction,
	                                       method: 'post',
	                                       encoding: 'utf-8',
	                                       async: false,
	                                       data: postvars_string,
	                                       onComplete : function(responseText)
	                                       {
	                                          daten = responseText;
	                                       }
	                                    }
	                             ).send();
   }
   else {
	   var myAjax = new Request.JSON(
	                                    {
	                                       url: '/includes/php/ajax/'+name_file+'.php?phpFunction=' + phpFunction,
	                                       method: 'post',
	                                       encoding: 'utf-8',
	                                       async: false,
	                                       data: postvars_string,
	                                       onComplete : function(responseText)
	                                       {
	                                          daten = responseText;
	                                       }
	                                    }
	                             ).send();
   }
    return daten;
}
//ende
