Galedajs Posted August 10, 2011 Report Share Posted August 10, 2011 Sveiki! Man ir nepieciesams izsaukt php funkcijas speciala javascript scripta. Sads ir mans kods: <script type="text/javascript"> function say(money){ if(value === false) { alert(value); }else { <?php savienojas ar db un kope kaut ko ieksa. ?> alert(value); } } </script> Bet problema tada, ka php tiek izsaukts uzreiz, ka lapa ieladejas. Un bez jebkadas parbaudes. Esmu meginajis ari otrada seciba if izmantot, bet nekadas atskiribas. Quote Link to comment Share on other sites More sharing options...
briedis Posted August 10, 2011 Report Share Posted August 10, 2011 (edited) Nu bet dooh, php servera puses valoda (izpildās uz servera), bet javascripts ir klienta puses valoda (izpildās uz klienta pārlūka). Izmanto AJAX. http://api.jquery.com/jQuery.ajax/ Bet šaubos, vai pašam tev kaut kas izdosies, jo izkskatās, nav izpratnes par pašām pamata lietām, tā kā veselīgi būtu sākt ar tām... Edited August 10, 2011 by briedis Quote Link to comment Share on other sites More sharing options...
Galedajs Posted August 10, 2011 Author Report Share Posted August 10, 2011 Par AJAX neko nezinu, bet tad skatisos. Tad nav nekada varianta, ka var izsaukt php funkciju no javascript if statement? Quote Link to comment Share on other sites More sharing options...
briedis Posted August 10, 2011 Report Share Posted August 10, 2011 Par AJAX neko nezinu, bet tad skatisos. Tad nav nekada varianta, ka var izsaukt php funkciju no javascript if statement? Nu nevari tu izpildīt php kodu pa tiešo no pārlūka, tāpēc, ka php izpildās tikai servera pusē. Ar ajax tu vari veikt jaunu pieprasījumu uz serveri, kas tad arī varētu izpildīt kaut kādu kodu. Quote Link to comment Share on other sites More sharing options...
Galedajs Posted August 10, 2011 Author Report Share Posted August 10, 2011 Skaidrs. Dosos uz google un skatisos ka izmanto AJAX. Paldies tad par palidzibu. Quote Link to comment Share on other sites More sharing options...
mad182 Posted August 10, 2011 Report Share Posted August 10, 2011 http://api.jquery.com/jQuery.get Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.