does anyone know if possible or how to submit a form, use get to get a posted varable, pass it via ajax to a php function then return the data?
we currently have it on a normal form submit and using smarty to return the data but ive come across the problem with placing this inside a tab so though best to do ajax based to prevent reloading of the page – current working code is as follows:
{assign var="postocde" value=$smarty.request.postcode}
{assign var="postcode_var" value=$postocde|fn_get_found_locations}
{assign var="postcode_final" value=$postcode_var}
<div id="postcode_result" {if $postcode_final == '1' || $postcode_final == '2'}class="postcode_result"{/if}>
{if $postcode_final == '1'}
{$lang.restricted_shipping_fail}
{elseif $postcode_final == '2'}
{$lang.restricted_shipping_success}
{/if}
</div>
<form method="get" action="{$seo_url.href}" name="restricted_locator" id="restricted_locator" class="cm-ajax">
<div class="form-field">
<label for="postcode">{$lang.restricted_shipping_label}:</label>
<input type="text" value="" name="postcode" size="50" class="input-text cm-hint" id="postcode" />
</div>
<input id="submit_postcode" type="submit" value="search" class="moreButton" />
</form>
really appriciate is someone could help or shed some light on this
Cheers!
Just use the jQuery AJAX call. It will return what ever is echoed out from the php page processing the request. So if you need multiple variables back you can have it echo a JSON string.
Script on page:
PHP script to send to:
If you already have a function defined you can just post it in like this. It may be easier to just reformat the function into it’s own page rather than incorporating it into a page.
EDIT: Regarding your undefined function error
You must include jQuery in the head of your document: