如何从javascript/jQuery调用新网页 [英] How can I call a new web page from javascript / jQuery
本文介绍了如何从javascript/jQuery调用新网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个像这样的按钮:
I have a button like this:
<button id="CreateButton" title="Create Task">Create Task</button>
我编写了捕获点击事件的代码:
I wrote code to capture the click event:
$('#CreateButton').click(function (event) {
event.preventDefault
var datastore = $("#SelectedDatastore").val();
xxxxxx
});
但是我想通过单击在我的MVC控制器上使用某些参数调用一个动作方法.例如数据存储的参数和值.
But I want make the clicking call an action method on my MVC controller with some parameters. For example the paramater and value of datastore.
推荐答案
如果只想转到另一个页面,则可以更改位置:
If you just want to go to another page, you could change the location:
window.location = "MyPage.aspx?paramater=MyParamValue";
或者,如果您不想更改当前页面,而只是执行一个操作,请使用 jQuery.get()
Or if you don't want to change the current page, but just to execute an action, use jQuery.get()
$.get("MyPage.aspx", { paramater: "MyParamValue" }, function(data) {
alert("Response from the server: " + data);
});
这篇关于如何从javascript/jQuery调用新网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文