<script language='javascript' type='text/javascript' charset='<?=$page_charset?>'>
$(document).ready(function(){
$('#btn_login').click(function(){
$.search_keyword();
});
});
here is the script
<form name='frm_search_keyword'>
<table style='width:250px;'>
<tr>
<td style='width:100px;'>
Search
</td>
<td>
<input type="text" name="web_keyword" />
</td>
<td>
<input type="submit" id="btn_login" name="btn_login" value="search!" />
</td>
</tr>
</table>
</form>
here is the form
search_keyword:function(type)
{
$.ajax({
type: 'POST',
url: '/web_keyword',
data: {'b_type':type},
cache: false,
async: false,
success: function(result){
if(result == 12001)
{
alert('please choose your interest.');
location.href = '/account/interest';
}else
location.href = '/'+type+'/'+result;
}
});
}
It successfully sends ‘web_keyword’ to db query and get result.
but I can’t get type data through ajax script.
Can you help me to ‘type’ data from the form table to ajax script?
Thank you.
I’m not exactly sure if this is the problem, but it is suspect:
Where is “type” supposed to come from? What is “type” referring to? Is “type” a value returned from your DB query? Or is it something selected by the user when they perform the search?
If type is something within your form element, then use Javascript or jQuery, or whatever, to “harvest” that value from the page, and then you will need to pass that data to the AJAX functionality.
You just need to get “type” from where ever it is being generated and/or stored and pass it to your AJAX function.
Also, maybe this is irrelevant, but your “search_keyword()” function definition looks odd to me…
Instead of:
Should be:
One final thing, could you tell us which Javascript library you are using?