【问题标题】:How do I post multiple parameters to a URL如何将多个参数发布到 URL
【发布时间】:2016-11-10 08:42:15
【问题描述】:

我需要发帖到这个网址

https://liceoeuroamericano.territorio.la/webservices/persona.php


我需要发布 2 个不同的参数

  1. 方法
  2. 参数

       method=activateUser
    
       param 
       {    
            "auth_key": "123456",
            "user": "[email]",
            "active":"[0/1]"
       }
       string(JSON)
    

我尝试了什么 - 我做对了吗?

<button id="activateUser">GO</button>
<script>
$('#activateUser').on('click', function(){


  $.post('https://liceoeuroamericano.territorio.la/webservices/persona.php',    

   {
    method=activateUser&params={    
    "auth_key": "123456",
    "user": "[email]",
    "active":"[0/1]"
   }
   string(JSON)
   }, function(data){

   })   

});

</script>

【问题讨论】:

  • {method=...}?这甚至不是有效的javascript。
  • 检查你的控制台,它帮助你!

标签: php jquery ajax post parameters


【解决方案1】:

如果我了解您的要求,您需要将 method 作为字符串传递,然后 JSON 编码 params 对象。如果是这样,这应该适合你:

$.post('https://liceoeuroamericano.territorio.la/webservices/persona.php', {
    method: 'activateUser',
    params: JSON.stringify({    
        auth_key: "123456",
        user: "[email]",
        active: "[0/1]"
    })
}, function(data){
    console.log('request completed successfully');
}) 

【讨论】:

  • 谢谢罗里,方法是一个参数
猜你喜欢
  • 2019-12-03
  • 1970-01-01
  • 2022-01-23
  • 2015-07-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多