Domanda

Lasciami iniziare dicendo che potrebbe sembrare semplice ma sto trovandolo estremamente difficile.

IVE ha fatto uno script di ricerca che utilizza PHP e per recuperare un risultato sarebbe simile a questo

search.php?term=alice&submit=Submit

Stuff standard .. Problema è, uso uno SPI con Ajax e PHP Quindi i miei risultati dovrebbero caricare dinamicamente in un div, pur mantenendo il valore hash, se non perdere la pagina L'utente aveva visitato il precedente .

jquery.history.js è il plugin che uso per il supporto del pulsante Indietro, che richiede che i collegamenti siano come tali:

<a href="#home">Home Page</a>

Questo caricare 'home.html' in un div denominato PageContent. Per quanto ne so, non c'è modo di chiamare i file PHP a meno che tu non sviluppi un piccolo hack, che ho,

Ecco il mio JavaScript / JQuery per il mio modulo di ricerca:

<script language="JavaScript">
$(document).ready(function() { 
    // bind form using ajaxForm 
    $('#search1').ajaxForm({ 
        // target identifies the element(s) to update with the server response 
        target: '#pageContent', 

        // success identifies the function to invoke when the server response 

        success: function() { 
            $('#pageContent'); 
            var hash = '#search.php?term='+($('#query').val()+'&submit=Submit').replace(/ /g, '+');
            var stripped = hash.replace(/(<([^>]+)>)/ig,""); 
            update(window.location.hash = stripped);

        } 

    }); 
});

</script>
.

Ecco la forma:

<form id="search1" action="search.php" method="post">
    <input id="query" type="text" name="term" />
    <input type="submit" name="submit" value="Submit" />
    </form>
.

Il mio problema è questo: ho provato this.form.reset();: reimpostazione di una forma multi-stage con jQuery , ma nessuno di questi lavori. Per favore aiutami se conosci un modo di fare questo ..

È stato utile?

Soluzione

$('#query').val(DefaultValue);

with this u can set your value to whatever you want, like blank: '';

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top