简体   繁体   English

无法使用cBox弹出窗口在joomla中获取JFactory :: getApplication

[英]Unable to get JFactory::getApplication in joomla using cBox popup

I am Developing popup component for joomla site, The Pop up Working Great , In my Popup i get phone number from user, i need to store that phone number to joomla database , but i am unable to call JFactory::getDBo(), when i call these method , popup was not working, i am in trouble , any help will be appreciate me.. thanxs in advance... 我正在为joomla网站开发Popup组件,The Popup Working Great,在我的Popup中,我从用户那里获得电话号码,我需要将该电话号码存储到joomla数据库中,但是当出现以下情况时,我无法调用JFactory :: getDBo()我叫这些方法,弹出窗口不起作用,我很麻烦,任何帮助都会感谢我.. thanxs提前...

site/default.php

 <script>
  function openColorBox() {
    $.colorbox({
      innerWidth:500, 
      innerHeight:300, 
      iframe:true,
      href: "subscribe.php",
      overlayClose:true,
      onLoad: function() {
        $('#cboxClose').remove();
      }
    });
  }
  setTimeout(openColorBox, 1000);
</script>

site/subscribe.php 网站/ subscribe.php

 <body class="oneColFixCtr">
<div id="container">

  <form name="Mail_list" action="#" method="post">

    <p>
      <label for="phone">Your Mobile Number </label>
      <input type="tel" name="phone" id="phone" size="10"  pattern="\d{10}" required />
      <input type="hidden" name="date1" id="date1" value="<?php echo date('d.m.y'); ?>" />
    </p>
    <input type="submit" name="submit" value="Enter">
  </form> 
</div>

Your form is not posting the data anywhere when sumitted. 提交表格时,您的表单不会在任何地方发布数据。 Your action="#" will never allow the form to submit. 您的action =“#”将永远不允许表单提交。 Set your action to PHP_SELF if you need to submit it back to subscribe.php, then have a check in your subscribe.php that processes your form. 如果需要将其提交回subscribe.php,则将操作设置为PHP_SELF,然后在subscribe.php中签入一个处理表单的检查。

The better method would be to have your popup content in a hidden div and open that div instead of using an iframe. 更好的方法是将弹出式内容放在隐藏的div中,然后打开该div而不是使用iframe。 Use subscribe.php as your logic for saving the users data to the database. 使用subscription.php作为将用户数据保存到数据库的逻辑。 Using ajax to submit the form wouldn't be a bad idea either. 使用ajax提交表单也不是坏主意。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM