简体   繁体   中英

How to pass a value from default.php to view.html.php through ajax - joomla3.x

I want to pass a value to view.html.php from default.php.

This is in Joomla 3.x

  • folder/tmpl/default.php
  • folder/view.html.php

default.php

<input placeholder="Enter a value" type="text" id="field-5" >

<script type="text/javascript">
$(document).ready(function() {
   $("#field-5").keyup(function (e) { 
      var exam = $(this).val(); 
      $.post('http://localhost/folder/folder/folder/folder/folder/view.html.php', {'value':exam});  
   });
});
</script>

view.html.php

$value = $_REQUEST['value'];
echo $value;

i need that $value for filtering a data table, i dont know if this is working or this the right code, or its just i need to refresh my data table and i dont know how.

Thanks in advance.

It doesn't work this way. Your URL in the ajax call must be something like the following:

JURI::root().'index.php?option=com_your_extension&view=view_name'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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