您好我选择框并提交按钮并依赖于我想将表单结果发送到ajax的提交并检索数组结果。 这是我的PHP代码:
if($param['aktion'] == 'get-widget-news-edit')
{
$html = '<form name="UserInformationForm" method="POST" >
<table id="news"> ';
if(($post['news'])==4){
$sql=" SELECT DISTINCT ad_news_texte.headline, ad_news.datum_archiv
FROM ad_news_texte
INNER JOIN ad_news_oe ON ad_news_texte.news_id = ad_news_oe.id_ad_news
INNER JOIN ad_news ON ad_news_oe.id_ad_news = ad_news.id
WHERE ad_news.datum_archiv
BETWEEN curdate( ) - INTERVAL DAYOFWEEK( curdate( ) ) +28
DAY AND curdate( )
";
$sql_select=mysql_query($sql);
while($row = mysql_fetch_array($sql_select)) {
echo $row['headline'] . " " .$row['datum_archiv'] ;
echo "<br>";
}
}
$html .= '<select name="news" id="news">
<option value="4" '. (($_POST['news']=="4") ? "selected=selected" : "" ) .'>Show news from last 4 weeks</option>
</select>
</table>
'.CreateButton($page['button']).'
</form>
<div class="form_result"> </div>';
$return = array(
'status' => 1,
'html' => $html
);
echo json_encode($return);
die();
}
Js代码将选择框数组结果发送到ajax但无法执行此操作..
function saveNewsWidget()
{
var selectBoxValue = $('#UserInformationForm').find('.form_result').html();
$.ajax({
type: "POST",
url: "ajax/dashboard.php",
dataType : 'json',
cache: false,
data: {'aktion' : 'save-widget-news', 'news' : selectBoxValue },
success: function(data)
{
//$('#news').html(data.html);
getNewsWidget();
//getNewsWidget();
$('#news').html(data['html']);
}
});
}