我在twitter bootstrap表单向导中使用了两个下一个按钮(.button-next)。第一个标签为“保存”,第二个标签为“保存并继续”。现在,在onNext事件中,如何跟踪请求来自哪个按钮?
我尝试使用$(this).text();
抓取按钮文字,但该文字无效。
CODE:
onNext: function (tab, navigation, index) {
success.hide();
error.hide();
if (form.valid() == false) {
return false;
}
if (index === 2)
{
if($(this).text() === 'save') // this condition is not working
{
return false;
}
var url = $('#desurl').val();
var language = $('#language').val();
var description = $('#description').val();
var features = $('#features').val();
$.ajax({
method: "POST",
url: url,
data: { language : language, description : description, features : features },
dataType: "json",
complete: function(){
}
});
}
handleTitle(tab, navigation, index);
}
答案 0 :(得分:0)
<form action="demo,php" method="post">
<button name="whichbutton" type="submit" value="btn1">Save</button>
<button name="whichbutton" type="submit" value="btn2">Save on Continue</button>
</form>
如果是php
echo $ POST [“whichbutton”]