gonliSs Posted July 30, 2014 Share Posted July 30, 2014 Hello, I've such form: <form action="{$link->getPageLink('index', true)|escape:'html':'UTF-8'}" enctype="multipart/form-data" method="post" id="send_question"> <p>{l s='Jeśli masz listę produktów i wiesz czego szukasz'}<br> {l s='dodaj poniżej plik w formacie np. pdf, doc, xls.'}</p> <div class="form-group"> <input type="file" id="firstFile" name="firstFile"> </div> <div class="form-group"> <input type="file" id="secondFile" name="secondFile"> </div> <div class="form-group"> <label for="inputEmail">{l s='Na ten adres prześlemy wycenę oraz dostaniesz kopię tej wiadomości'}</label> <input type="email" class="form-control" name="inputEmail" id="inputEmail" placeholder="{l s='Twój adres email'}"> </div> <div class="form-group"> <label for="inputPhone">{l s='Poinformujemy cię o wysyłce wyceny'}</label> <input type="text" id="inputPhone" name="inputPhone" class="form-control" placeholder="{l s='Twój numer telefonu'}"> </div> <div class="form-group last-formgroup"> <label for="inputComment">{l s='Napisz komentarz o czym jeszcze powinniśmy pamiętać'}</label> <textarea class="form-control" rows="3" id="inputComment" name="inputComment"></textarea> <input type="hidden" name="submitThisForm" value="1"> <button type="submit" name="submitQuestion" id="submitQuestion" class="btn btn-default"> <span>{l s='Wyślij'}</span> </button> </div> </form> and I'd like to send it in ajax way. If I send it without ajax it works good, it sends email with attachments. But it has to be ajax form. How can I pass data from that form to index controller? I've such code by now and I don't know what to do next: $(document).on('submit', '#send_question', function(e){ e.preventDefault(); $.ajax({ type: 'POST', headers: { "cache-control": "no-cache" }, url: baseUri + '?rand=' + new Date().getTime(), async: true, cache: false, dataType : "json", data: 'controller=index&ajax=true', success: function(jsonData) { console.log(jsonData); } }); }); Thanks for help. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now