lynxus Posted September 28, 2010 Share Posted September 28, 2010 Hi Guys, I have a question.. I have the below html5 code that will show a html5 notification: <script> function RequestPermission (callback) { window.webkitNotifications.requestPermission(callback); } function showNotification(){ if (window.webkitNotifications.checkPermission() > 0) { RequestPermission(showNotification); } else { window.webkitNotifications.createNotification("http://a1.twimg.com/profile_images/710503034/lillypad_rss_normal.png", "TITLE", "Hello, Im a message.").show(); } } </script> How can I use ajax to call notify.php and if notify.php returns the value of "1" the page / ajax will then call the showNotification() function? Please anyone? This is killing me and I suck @ JS / Ajax / Jquery.. An example code would be ace. Essentially im looking for something like. ajaxrequest="notify.php" if ajaxrequest.answer = "1" { showNotification(); } Any thoughts? Quote Link to comment https://forums.phpfreaks.com/topic/214639-run-js_function-if-ajax-response-1-please-read-you-may-be-able-to-help/ Share on other sites More sharing options...
lynxus Posted September 28, 2010 Author Share Posted September 28, 2010 This has been resolved from some fellows over at webmaster-talk.com $(document).ready(function() { $.ajax({ url: 'notify.php', success: function(data) { if (data == "1") { showNotification(); } } }); }); Quote Link to comment https://forums.phpfreaks.com/topic/214639-run-js_function-if-ajax-response-1-please-read-you-may-be-able-to-help/#findComment-1116840 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.