It is easy to use fpCGI with AJAX. I use it to send JSON formatted data back and forth all the time.<br><br>You can either use a form already on the page, or build one on demand with javascript.<br><br>Make sure you have all the usual fields in the form for fpCGI submission.<br>
<br>From filePro, you just write out whatever you want to go back (I use JSON, as I mentioned) and parse it on the client side. I have a JSON javascript class that does this for me (I could just use eval to instantiate the object literal, but that's not very robust or secure). (eg) instead of "<b>responseJson = eval(XHTP.responseText);</b> " I use "<b>responseJson = JSON.parse(XHTP.responseText);</b>". <br>
<br>You can grab the JSON class at <a href="http://www.json.org/json2.js">http://www.json.org/json2.js</a> if you like.<br><br>FYI, you can also use PHP to create a direct socket connection to fpCGI and retrieve the data that way, as well. <br>
<br>(eg)<br><b> $sPost ="";<br> $aPost =array();<br> $aPost["Field_ddir"] ="/usr/local/apache/htdocs/";<br> $aPost["Field_base"] ="ajax";<br>
$aPost["Field_cmd"] ="rreport someTable -fp someProcessing -sr ".rand(1,500)." -n -u -y automaticAJAX";<br> $aPost["someField"] ="some data";</b><br>
<b> //.....etc....</b> <br><br> <b>foreach ($aPost as $sFieldName=>$sFieldValue) {<br> if(!$bFirst) { $sPost .="&"; }<br> $sPost .=urlencode($sFieldName)."=".urlencode($sFieldValue);<br>
$bFirst =false;<br> }</b><br><b> //you could write this all to the string directly instead of using an array, <br></b><b> //</b><b>I just find it's clearer code to do it with an array </b><br>
<br> <b>$sHeader ="POST /cgi-bin/fpcgi HTTP/1.1\n"<br> ."Host: $yourServersIp\n"<br> ."Connection: Close\n"<br> ."Content-Type: application/x-www-form-urlencoded\n"<br>
."Content-Length: ".strlen($sPost)<br> ."\n\n$sPost\n";<br> <br> $oSocket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);<br> $bSuccess = socket_connect($oSocket, $yourServersIp, 80);<br>
<br> $iBytesSent =socket_write ($oSocket, $sHeader);<br> <br> $sResponse = "";<br> <br> while ($c =socket_read($oSocket, 2056)) { $sResponse .=$c; }<br>
<br> socket_close($oSocket);</b><br><br><br>Feel free to hit me up if you have any questions.<br><br>-- <br>Tyler Style<br><a href="http://malthusiansolutions.com">http://malthusiansolutions.com</a><br>
<br><div class="gmail_quote">On Thu, May 21, 2009 at 12:30 AM, <span dir="ltr"><<a href="mailto:filepro-list-request@lists.celestial.com">filepro-list-request@lists.celestial.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Date: Wed, 20 May 2009 05:53:32 -0700<br>
From: <a href="mailto:jsola@newportsales.com">jsola@newportsales.com</a><br>
Subject: AJAX and FPCGI<br>
<br>
I am trying to use AJAX with FPCGI without success. I have "tricked" FPCGI by<br>
generating external files and combining my code with some PHP code with<br>
success. However, this have been a solution for simple code. No success for<br>
complex code. Does any one know how to direclty use AJAX with FPCGI.<br>
<br>
Att.<br>
Juan<br>
</blockquote></div><br>