Posting Forms using $.post

Posting Forms using $.post


Hello list,
I have a running setup for posting a form to a server without any java
script. This is also working with chars like ö ä ü and so on. Now I
want to post this form using jquery and replace the content of a div
with the posts response. This is also working, but it messes up the
posted content in case of special characters. Here I what I do:
<script type="text/javascript">
var customerSearcherTimer = null;
    function customerSearcherTimeoutSearch() {
        clearTimeout(customerSearcherTimer);
        customerSearcherTimer = setTimeout( function() {
            customerSearcherSearch();
        }, 1000);
    }
    function customerSearcherSearch() {
        var form = $j('#customerSearcherForm');
        var results = $j('#customerSearcherResults');
        results.html('<div class="spinner"></div>');
        var xhr = $j.post(form.get(0).action, {searchCustomers: '',
searchString: $j('#customerSearcherFormText').get(0).value } ,
function(html) {
            setHtmlIntoElement(results, html, xhr);
        });
    }
    function customerSearcherSort(orderBy) {
        var form = $j('#customerSearcherForm');
        var params = {searchCustomers: '', searchString:
$j('#customerSearcherFormText').get(0).value, orderBy: orderBy}
        var results = $j('#customerSearcherResults');
        results.html('<div class="spinner"></div>');
        var xhr = $j.post(form.get(0).action, params, function(html) {
            setHtmlIntoElement(results, html, xhr);
        });
    }
    $j(function() {
        $j('#customerSearcherFormText').keyup(function() {
            customerSearcherTimeoutSearch();
        });
    });
</script> <s:form id="customerSearcherForm" beanclass="${actionBean.class}">
    <p class="ui-widget"><fmt:message key="customerSearcher.searchCustomer" />
    <s:text id="customerSearcherFormText" name="searchString"
tabindex="999999"/>
</s:form>
I also tried using form.serialize without success. Now can't find a
solution and hope that one of you can help me :-)
Thanks,
Richard
--
Richard Hauswald
Blog: http://tnfstacc.blogspot.com/
LinkedIn: http://www.linkedin.com/in/richardhauswald