简体   繁体   English

使用$ .post将多变量从Javascript发送到PHP页面

[英]Sending Mulitple Variable from Javascript to PHP page using $.post

I'm trying to send 4 variables for a pagination page but am getting stuck in sending them. 我正在尝试为分页页面发送4个变量,但在发送它们时被卡住了。 Would someone be so kind as to explain for me. 有人会为我解释。

$('input#Query_Submit').on('click', function() {
    var PartNumber = $('input#Query').val();
        $("#Loading").show();
        ShowLoading = true;
    if ($.trim(PartNumber ) != ''){
        $.post('small-displays/Results.php', {
            Query: PartNumber ,
            pn: pn,
            last: last,
            rpp: rpp,
            }, function(data) {
        ShowLoading = false;

        $("#Loading").hide();
            $('div#Results-Data').html(data);
        });
    }
});

I think I'm using the wrong syntax to pass the variables? 我想我使用了错误的语法来传递变量?

Many Thanks in advance! 提前谢谢了!

EDIT- UPDATED MY VARIABLE NAMES AND TYPO'S In my haste I have mis-spelled and used incorrect variables - CORRECTED 编辑过的我的变量名和错字本我急忙拼写错误并使用了错误的变量-已纠正

I can't comment yet so answer it is. 我还不能发表评论,所以回答是。

Clarifications: 说明:

  • Are you sure that you pass this condition ($.trim(Query) != '') ? 您确定通过此条件($ .trim(Query)!='')吗?
  • Are you sure that all the variables are not undefined? 您确定不是所有变量都未定义吗?

Also check the console if there are errors or add some console.log() like this 还要检查控制台是否有错误或添加一些console.log()这样的

$.post('small-displays/Results.ph', {
      Query: Query,
      pn: pn,
      last: last,
      rpp: rpp,
},function(data) {

      ShowLoading = false;
      $("#Loading").hide();
      $('div#Resulsts-Data').html(data);

}).fail(function(err) {
      console.log(err)
});

Hope it helps. 希望能帮助到你。

Ok not sure why, how or what the .... 确定不知道为什么,如何或什么...。

I deleted it off the server and returned the same zero results... 我将其从服务器上删除,并返回了相同的零结果...

I then got thinking on whitespaces... 然后我开始思考空白...

For some, i have no idea reason, i changed a whitespace seperator :-> 对于某些原因,我不知道原因,我更改了空白分隔符:->

Query: PartNumber ,

Query: PartNumber,

And voila! 瞧! I think it may be down to some other reason, server lag, upload lag, download lag or some other variation of issue, but it's working lol 我认为这可能是由于其他原因造成的,例如服务器延迟,上传延迟,下载延迟或其他一些问题,但这是可行的

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

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