Last active
August 4, 2021 11:23
-
-
Save PetraMotz/8bc7c0400d1cc50755654d53a07652e0 to your computer and use it in GitHub Desktop.
jQuery #ajax #js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var url = new URL(location.href); | |
| url.searchParams.append('tx_webxgesundheitsfindernew_account[action]', 'ajaxAutoComplete'); | |
| url.searchParams.append('tx_webxgesundheitsfindernew_account[searchValue]', input.val()); | |
| data-url="<f:uri.action controller='Transaction' extensionName='webxstripe' pluginName='Stripepayment' action='sendMailAfterStripePayment' pageUid='{settings.paymentPage}' arguments='{transaction: transaction.uid, registration : registrationId}' />" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| jQuery.ajax({ | |
| async:'true', | |
| type: "POST", | |
| url: url, | |
| data: data, | |
| success: function (response) { | |
| var json = (JSON.parse(response)); | |
| $.each(json, function(index, value){ | |
| if(value > 0){ | |
| $('.nav-item').each(function(){ | |
| if($(this).attr('data-uid') == 'feed' && $(this).children('.hasNewElement').length > 0){ | |
| var currentCount = $(this).children('.hasNewElement').text(); | |
| var newCount = currentCount-value; | |
| if(newCount == 0){ | |
| //$(this).children('.hasNewElement').fadeOut(2000); | |
| } | |
| else{ | |
| } | |
| } | |
| }) | |
| } | |
| }) | |
| // do something with your loaded content | |
| // remove old more-button | |
| // init new more-buttons | |
| }, | |
| error: function(error){ | |
| //console.log(error); | |
| } | |
| }); | |
| <script> //wenn im view | |
| require(['jquery'], function($) { | |
| $(document).on('click', '.webxBackendAction', function() { ->eventlistener auf document, selector danach | |
| $(this).data('state', $(this).prop('checked')); | |
| $.ajax({ | |
| async:'true', | |
| url: TYPO3.settings.ajaxUrls['webx_seminars_ajax'], | |
| type: 'POST', | |
| data: $(this).data(), | |
| // dataTypes: 'json', | |
| success: function(result) { | |
| $('.webxAjaxResult').html('OK').show().delay("2000").fadeOut(); --meldung einblenden bei Erfolg | |
| $('.debugResult').html(result); | |
| }, | |
| error: function(error) { | |
| console.log(error); | |
| } | |
| }) | |
| }); | |
| console.log('done'); | |
| }); | |
| </script> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| TEmplate für jede Action anlegen auch wenn sie nicht für den ajax reload verwendet wird | |
| Beispiel gesundes Bayern | |
| wenn die ajax action etwas an jquery zurückgeben soll | |
| public function markAsReadAction() | |
| { | |
| $type = $_REQUEST['type']; | |
| //DebuggerUtility::var_dump($type); | |
| $count = 0; | |
| $result = array('count' => $count); | |
| die(json_encode($result)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $.get('/warenkorb/', function (cartHtml) { | |
| $('.tx-webx-products').replaceWith($(cartHtml).find('.tx-webx-products')); | |
| }); | |
| $.get ist die kurzschreibweise von | |
| $.ajax({ | |
| url: url, | |
| data: data, | |
| success: success, | |
| dataType: dataType | |
| }); | |
| das Element $('.tx-webx-products') wird hier mit einer aktuelleren Version von sich selbst überschrieben. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public function moreResultsAction() | |
| { | |
| $offers = null; | |
| if ($_REQUEST['contactType'] == 3) { | |
| $contacts = $this->contactRepository->getLimitedAmountOfContactsPerContactType($_REQUEST['searchParam'], 3, $_REQUEST['contactType'], $_REQUEST['offset']); | |
| } else { | |
| if ($_REQUEST['contactType'] == 2) { | |
| $contacts = $this->contactRepository->getLimitedAmountOfContactsPerContactType($_REQUEST['searchParam'], 3, $_REQUEST['contactType'], $_REQUEST['offset']); | |
| } else { | |
| if($_REQUEST['contactType'] == 1){ | |
| $contacts = $this->contactRepository->getLimitedAmountOfContactsPerContactType($_REQUEST['searchParam'], 3, $_REQUEST['contactType'], $_REQUEST['offset']); | |
| } | |
| else{ | |
| $offers = $this->offerRepository->getLimitedAmountOfOffers(3, $_REQUEST['offset'], $_REQUEST['searchParam']); | |
| } | |
| } | |
| } | |
| $output = ''; | |
| // DebuggerUtility::var_dump($offers); | |
| // DebuggerUtility::var_dump($contacts); | |
| if($offers != null){ | |
| $this->view->setTemplatePathAndFilename(ExtensionManagementUtility::extPath('webx_gesundheitsfinder') . '/Resources/Private/Partials/Contact/SingleOfferResult.html'); | |
| foreach ($offers as $offer) { | |
| $this->view->assign('offer', $offer); | |
| $output .= $this->view->render(); | |
| } | |
| } | |
| else{ | |
| $this->view->setTemplatePathAndFilename(ExtensionManagementUtility::extPath('webx_gesundheitsfinder') . '/Resources/Private/Partials/Contact/SingleResult.html'); | |
| foreach ($contacts as $contact) { | |
| $this->view->assign('contact', $contact); | |
| $output .= $this->view->render(); | |
| } | |
| } | |
| die($output); | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public function markAsReadAction() | |
| { | |
| $type = $_REQUEST['type']; | |
| //DebuggerUtility::var_dump($type); | |
| $count = 0; | |
| $unread = $this->feedRepository->getUnreadByTypeAndUser($this->user, $type); | |
| $count = $count + count($unread); | |
| foreach($unread as $unr){ | |
| $unr->setUnread(false); | |
| $unr->setUnreadInFeed(false); | |
| $this->feedRepository->update($unr); | |
| $persistenceManager = GeneralUtility::makeInstance(PersistenceManager::class); | |
| $persistenceManager->persistAll(); | |
| } | |
| $result = array('count' => $count); | |
| die(json_encode($result)); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| In typo3conf/ extensionname/ Configuration / Backend / AjaxRpoutes.php erstellen | |
| return [ | |
| 'webx_seminars_ajax' => [ | |
| 'path' => '/webx_seminars/ajax', | |
| 'target' => WEBCROSSING\WebxSeminars\Controller\SeminarController::class . '::ajaxAction', -->das ist die Controller Action die im Controller angesprochen werden soll | |
| ] | |
| ]; | |
| PHP autodump löschen!! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment