![](/img/trans.png)
[英]how can i pass my webform value in webapi controller as a model class using jquery ajax
[英]How can I pass my dropdown style value on to my php file via jQuery/ajax?
這是我的下拉菜單的標記:
<select id="themes">
<option selected="selected">Themes:</option>
<option value="default">Default</option>
<option value="red">Red</option>
<option value="bw">Black and White</option>
<option value="invert">Invert</option>
</select>
我現在正在使用的jQuery:
$("#themes").change(function() {
$.ajax({
url: "css/style.php",
method: "GET",
data: {"theme="+$(this).val(); }
})
});
這給了我一個控制台錯誤“ Uncaught SyntaxError:意外的標記+”。 我要做的就是將$ _GET ['theme']傳遞給我的style.php,這樣我就可以使用條件處理它。 有什么建議嗎?
將數據創建為對象,代碼中存在語法問題
$("#themes").change(function () {
$.ajax({
url: "css/style.php",
method: "GET",
data: {
theme: $(this).val()
}
})
});
像這樣做.............
$("#themes").change(function(){
var theme = $(this).val();
$.ajax({
url: "css/style.php",
method: "GET",
data: {theme : theme },
success: function(data) {
}//end of success
});
});
我一直使用這種技術,然后使用
$theme = $_GET['theme'];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.