Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery ajax not loading
    text
    copied!<p>I have an input with the purpose of being a part of a search engine, on wich I use jQuery to pre-filter the search string removing forbidden characters as long as other things. Recently I had to change the url of the website and used PHP to print a variable that would indicate the url for ajax requests (as I was doing before, except that now normal and ajax requests have different url's), and I found a problem that I can't figure out what it is.</p> <p>Basically the ajax request doesn't work (no actions and no request at all on Firebug). Tried every possible way (declaration inside the funcion, passed as argument, and so on) to tell my script the url I wanted, but it only works with the old url (even the ajax request never gets called).</p> <p>So I'd like you to check it and see if you find anything wrong.</p> <p>Here's the code :</p> <pre><code>$(function() { $('form#search-form').submit(function(e) { search(e, acc); }); $('a#search-submit').click(function(e) { search(e, acc); }); }); function search(e, l) { e.preventDefault(); var t = $('#search-text input[name="search-text"]').val(); //var l = $('#nav-ul li.sel a').attr('href'); $.ajax({ type: 'POST', url: l+'format_search_string', data: 's='+t, cache: false, dataType: 'json', success: function(response) { if (response.status == 'true') window.location = $('#search-submit').attr('href')+'/s:'+response.string; else jQuery.facebox('&lt;p class="facebox-notice"&gt;Necessita preencher o campo da pesquisa&lt;/p&gt;'); } }); } </code></pre> <p><strong>edit:</strong> "acc" is a variable containing the url, wich prints exacly what I want when I call it inside search() function, the only thing that does nothing is the ajax request (isn't called at all). If I use the old url, it works, but the strange thing is that with the new url, at least the ajax call should be made.</p> <p>The code is all in the same server and domain, and nothing as changed, just the url of the requests.</p> <p>normal request :</p> <pre><code>http://category.domain.com/ </code></pre> <p>ajax request :</p> <pre><code>http://www.domain.com/category </code></pre>
 

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