English 中文(简体)
如何在 jquery 中传递数据库值?
原标题:how to pass database values in jquery?

有多个( 超过 100 个) 以动态方式创建

我下载了jquery UI (http://jqueryui.com/demos/dialog/#option-position), 并用于我的工程。 现在我要通过每点击一盒公司代号, 从数据库获取细节。 如果我点击窗口 5, 公司代号 5 应该通过在对话框中获取公司的其他细节 。

jquery 代码 :

<script type="text/javascript">
     // increase the default animation speed to exaggerate the effect
     $.fx.speeds._default = 1000;
     $(function () {

         $("#dialog").dialog({
             autoOpen: false,
             show: "slide",
             hide: "explode"
         });

         $("div[id *=  window ]").live( click , function (e) {

             $("#dialog").dialog("open");

             return false;
         });
     });
    </script>

Asp. net 代码

<div id="dialog" title="Basic dialog">
     <div><%#Eval("comp_name")%> </div>
      <div><%#Eval("comp_city")%> </div>
 </div>
最佳回答
        $.fx.speeds._default = 1000;
        $(document).ready(function () {
            $("div[id*= window ]").live( click , function (e) {
                $.ajax({
                    url:  YourUrl , type:  Get , dataType:  json ,
                    data: { id: $(this).attr( id ).replace(/window/g,   ) },
                    success: function (data) {
                        $( <div></div> ).appendTo( body ).html( <div>  + data.comp_name +  </div><div>  + data.comp_city +  </div> ).dialog({
                            modal: true, title:  Test message , zIndex: 10000, autoOpen: true,
                            width: 460, height: 300, modal: true, resizable: false, closeOnEscape: false,
                            show: "slide", hide: "explode",
                            buttons: {
                                Ok: function () {
                                    $(this).dialog("close");
                                }
                            },
                            close: function (event, ui) {
                                $(this).remove();
                            }
                        });
                    }
                });
            });
        });

使用 asp.net mvc 3 吗?

$("div[id*= window ]").live( click , function (e) {
            alert( Id :   + $(this).attr( id ) +       +  Replaced Id   + $(this).attr( id ).replace(/window/g,   ));
        });

<div id="window1">
    Click Me1 !
</div>
<br />
<div id="window2">
    Click Me2 !
</div>
<br />
<div id="Div1">
    Click Me !. I am not window id.
</div>
<br />
<div id="window3">
    Click Me3 !
</div>

fro 现场演示见此链接 : http://jsfiddle.net/nanoquantumtech/865Su/

替换方法请参见此链接 : http://www.w3schololums.com/jsref/jsref_replace.asp

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签