Basis for Ajax tasks.
Simple extend with your own code.
Copy to:
root
- src
- - hh-com
- - - contao-simpleajaxrouting
Update your contao installation composer.json
"repositories": [
{
"type": "path",
"url": "./src/hh-com/contao-simpleajaxrouting",
"options": {
"symlink": true
}
}
],
"require": {
...
"hh-com/contao-simpleajaxrouting": "@dev",
...
}
Run composer: php -d memory_limit=-1 ./path/to/composer.phar update
This module provides the basis for your Ajax applications.
- Add your new route in /src/Resources/config/routing.yml
- Add your code in /src/Controller/SimpleAjaxRouting.php
- Create an ajax call in your html/js file
<input type="text" name="ajaxQuicksearch" id="ajaxQuicksearch" value="">
<script>
$("#ajaxQuicksearch").on("keyup", function(event){
$.ajax({
url: '/articlesearch/', // value from your routing.yml
type: 'POST',
dataType: 'json',
data: {
keyword: $(this).val(),
keyword2: "whotever2"
},
async: true,
success: function(data, status) {
console.log(data);
console.log(status);
},
error : function(xhr, textStatus, errorThrown) {
console.log(xhr);
console.log(textStatus);
console.log(errorThrown);
}
});
});
</script>