Note that there are some explanatory texts on larger screens.

plurals
  1. POProcessing a PHP request from an ajax-driven Fancybox element on the same page
    primarykey
    data
    text
    <p>I've been working on a little project that involves collecting/processing search results and I thought you guys may be able to lend a hand. I have a small script that takes a search value from a search input, processes it via PHP and then collects and inserts the results in a fancybox via JS. Thus far, all is going well but I can't seem to work out the next bit. </p> <p>I can't manage to interact with any elements in the fancy box because it will reload the page (for example, previous and next buttons or search input). How would you go about loading new content or form inputs into a fancybox on the same page instance using AJAX? </p> <p>HTML:</p> <pre><code>&lt;form action="search.php" method="post" name="search" id="search"&gt; &lt;input size="35" value="" placeholder="Search" name="search" id="result" autocomplete="off"&gt; &lt;button id="check" data-fancybox-type="ajax" href="search/search.php" id="check"&gt;Search&lt;/button&gt; </code></pre> <p></p> <p>Script:</p> <pre><code>jQuery(document).ready(function(submit) { $('#check').on("click", function (e) { e.preventDefault(); $.ajax({ type: "POST", cache: false, url: "search.php", data: $("#result").serializeArray(), success: function (data) { // on success, post returned data in fancybox $.fancybox(data, { // fancybox API options fitToView: true, openEffect: 'fade', closeEffect: 'fade' }); } }); }); }); </code></pre> <p>The above script is largely basses on <a href="https://stackoverflow.com/a/14343547/2636021">this post</a></p> <p>Thanks for your ideas!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload