繁体   English   中英

如何将参数传递给javascript中的URL?

[英]how to pass parameter to URL in javascript?

我需要将参数传递给URL。我已经摆好了代码。

如何将在文本框中输入的usernamepassword传递给代码中的网址。感谢您的帮助。

您不应在URL中发送password

如果要传递其他一些详细信息:如下更新这两行:

             data: {data1:$("input#data1").val(),data2:$("input#data2").val()},
             url: "http://localhost:53179/hdfcmobile/hdfc.ashx",

如果要传递url参数,则要使用:

type: 'GET'

并且:

url: 'http://localhost:53179/hdfcmobile/hdfc.ashx

到.ajax配置中,使用类型:“ POST”会将字段发布到标头(而不是url)中。

试试下面的代码:

您可以按这种模式尝试代码...

var sdate = $('#banners_startdate').val();

var edate = $('#banners_enddate').val();

        if(sdate != '' && edate != ''){
            $.ajax({
                url: 'your url',
                data: 'apiname=get_banner_stat_platform_sharing&var=bannerstats&sdate=' + sdate + '&edate=' + edate,
                dataType: 'html',
                success: function(data){ 
                                         $('#bannerstats').html(data);
                                          return false;
                                       }
            });
        }

可以通过id获取用户名和密码的位置:

function ajaxcall(username,password)
   {
         jQuery.ajax({

                      type: "POST",

                      url: "Enter Url to pass",

                      data: {user: username, pass: password},

                      dataType: "html",

                      success: function(data) {
                          //write code what you want to do here
                      }

         });

   }

您可以通过$_POST['user']$_POST['pass']来获取页面上的值。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM