php, how to call a javascript function?
-
i am trying to use gigya auth properties to login users on my website. They have a function that needs to be called after i authenticate the credentials as seen in this http://developers.gigya.com/index.php?title=Template%3a~gs_Authentication_common_implementation I have a form and when i submit the form i send it to login.php where i authenticate my users. My question is how do i call socialize.notifyLogin?. this is the javascript: <script type="text/javascript"> var conf = { APIKey:'2_9E9r_ojXEqzZJqKk7mRqvs81LtiSvUmBcm' }; </script> <script type="text/javascript"> var secret = 'eIqtclW2CxC6qvmT55MvOxZ5Rm7V5JhBV/gioJLKIxM='; var yourSiteUid= '<?php echo $talentnum;?>'; // siteUID should be retrieved from your user management system function your_b64_hmac_sha1(secret, datePlusSite) { var b64Sig = ''; // Place your implementation here ... return b64Sig; } function printResponse(response) { if ( response.errorCode == 0 ) { alert('After notifyLogin'); } } var dateStr = getCurrentTime(); var datePlusSite = dateStr + "_" + yourSiteUid; var yourSig = your_b64_hmac_sha1(secret, datePlusSite); var params={ siteUID:yourSiteUid, timestamp:dateStr, signature:yourSig, callback:printResponse }; gigya.services.socialize.notifyLogin(conf,params); </script> to be more clear i set the $talentnum; inside my login.php. so i have the form i send it ti the login.php and a redirect page... Where the call to socialize.notifyLogin will be? thanks, any idea helps
-
Answer:
You have two options: If you call login.php as the target of an HTML form, you should redirect the user to a new HTML page upon successful login. This new HTML page should contain the socialize.notifyLogin call. If you call login.php via an AJAX request, you should call socialize.notifyLogin in the "success" callback of the AJAX request. In no case, however, will you be able to execute the Javascript function directly from your PHP script. PHP executes on the server before the Javascript is sent to the user as output with your HTML document, and therefore cannot execute Javascript functions directly.
Patrioticcow at Stack Overflow Visit the source
Other answers
PHP is executed before the page loads, therefore you cannot call a JavaScript function from PHP.
Brian Graham
Related Q & A:
- How to access a nested function from another nested function in javascript?Best solution by devarticles.com
- How to call a function with parameter in a bash script?Best solution by tldp.org
- how to call a function in Python in another function?Best solution by Yahoo! Answers
- How to call a function asynchronously in PHP?Best solution by Stack Overflow
- How to graph a quadratic function on a graphing calculator?Best solution by ChaCha
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.