标签: http-post

rails post request

我不太了解如何在rails中处理请求,在我的控制器中,我有这样的事情:

def method_to_handle_request
  # do stuff
end
Run Code Online (Sandbox Code Playgroud)

然后在视图中我有这个JavaScript:

$.post("/", {method_to_handle_request: "value"}, function(data) {
  // do something with data
});
Run Code Online (Sandbox Code Playgroud)

这是错误的:data在JavaScript中最终只是作为页面.因此,我的问题是:如何处理rails中的请求?我一直在阅读"使用Rails进行敏捷Web开发",而那里的部分对我来说并没有多大意义.谢谢

ruby ruby-on-rails http-post

3
推荐指数
1
解决办法
3367
查看次数

通过 URL 传递表单变量

我想要完成的是通过简单地在 URL 中输入表单变量来登录网站。

HTML代码:

    <form action="httpclient.html" onsubmit="return checkSubmit();" method="post"           target="_parent" name="frmHTTPClientLogin">
    <input type="hidden" name="mode" value="191">
    <label>Username</label>
    <input border="1" style="width:150px" maxlength="60" name="username">
    <label>Password</label></pre>
    <input type="password" border="1" style="width:150px" autocomplete="off" name="password" maxlength="60">
Run Code Online (Sandbox Code Playgroud)

这是代码的相关过去。现在我想通过传递在 url 中键入的值来登录到这个站点http://10.100.56.55/httpclient.html。首先有没有可能。如果是,那么我究竟需要为用户名输入什么:名称和密码正在通过?如果有的话,什么编码的 URL 将在 POST 方法中传递?

html forms url http-get http-post

3
推荐指数
1
解决办法
6万
查看次数

从android发布文件时的内存问题

当我尝试从我的Android应用程序上传图像或更大的文件时,它会崩溃并出现OutOfMemoryException.我想知道是否有其他方法可以做到这一点.

我在两个不同的地方崩溃了应用程序:

Base64.encodeToString(bytes, Base64.DEFAULT);
Run Code Online (Sandbox Code Playgroud)

这里base64字符串是nameValuPairs集合中的值之一.

HttpClient client = new DefaultHttpClient();
HttpPost httppost = new HttpPost(uo.WebServiceURL);
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(nameValuePairs); // On this line
httppost.setEntity(entity);
HttpResponse response = client.execute(httppost);
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

memory android http-post

3
推荐指数
1
解决办法
1627
查看次数

Android上的HTTP POST

我想对php脚本做一个简单的HTTPRequest,我试图制作最基本的应用程序以使功能正常工作.我想测试我的应用程序正在发送我提供的数据,所以我已经将Android应用程序发送到服务器,该服务器应该向我发送我已经放入应用程序的数据."postData"函数的代码是将数据从android发送到服务器,"default.php"的代码是Web服务器上的接收php文件,然后将数据转发到我的电子邮件地址(未给出).这是代码

    public void postData() {

    // Create a new HttpClient and Post Header
    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost("http://somewhere.net/default.php");

    try {
        // Add your data
        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
        nameValuePairs.add(new BasicNameValuePair("thename", "Steve"));
        nameValuePairs.add(new BasicNameValuePair("theage", "24"));
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

        // Execute HTTP Post Request
        //HttpResponse response = httpclient.execute(httppost);

        // Execute HTTP Post Request
        ResponseHandler<String> responseHandler=new BasicResponseHandler();
        String responseBody = httpclient.execute(httppost, responseHandler);

    //Just display the response back
    displayToastMessage(responseBody);

    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block …
Run Code Online (Sandbox Code Playgroud)

php android http-post

3
推荐指数
1
解决办法
6139
查看次数

HTTP 错误 405.0 - 不允许的方法 - POST 失败

我有一个 HTML 网页,它应该提交回自身,但如果 method="POST",则经常失败。它适用于 GET,但我们真的想要 POST。我已经删除了所有代码,直到只剩下一个输入和一个提交,但它总是得到 405 错误。这个临时网页已尽我所能精简。

我正在运行 IIS 7 的 PC 上运行此测试。

<form id="form1" action="PhoneTest3.html" method="POST">
    <label for="contactPhoneExt">Contact Phone: </label>
    <input id="contactPhoneExt" name="contactPhoneExt" />
    <br/>

    <input type="submit" value="Submit" />
</form>
Run Code Online (Sandbox Code Playgroud)

我错过了什么?

html http-post

3
推荐指数
1
解决办法
8260
查看次数

Objective-C-> JSON-> PHP Array

过去几天我一直在努力奋斗; 我试图将数组发布到PHP.我可以成功发送它,但它没有使用后变量(我试图使用变量键"json"...使用此代码,我在php中收到数组:

Objective-C的

NSError *error;
NSDictionary *jsonDictionary = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects: @"one", @"two", @"three", nil] forKeys: [NSArray arrayWithObjects: @"a", @"b", @"c", nil]];
NSArray *jsonArray = [NSArray arrayWithObject:jsonDictionary];
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonArray options:NSUTF8StringEncoding error:&error];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"somewebservicelocation/arrayTest.php?json="]];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:jsonData];
NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSString *response = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];
NSLog(@"response: %@",response);
Run Code Online (Sandbox Code Playgroud)

PHP

$handle = fopen('php://input','r');
    $array = fgets($handle);
    echo $array;
    if(isset($array))
    {
        echo "success";
    }
    else
    {
        echo …
Run Code Online (Sandbox Code Playgroud)

php arrays objective-c http-post

3
推荐指数
1
解决办法
3672
查看次数

提交时Django Forms BooleanField返回'on'

您好,我是Django Forms的新手.我想在我的表单中添加一个复选框.当我提交表单时,我希望复选框字段应该返回True或False(取决于是否选中复选框).

但是如果选中该字段则发布'on',如果未选中该字段则发布任何内容.以下是我的表单中的代码段:

from django import forms
class MyForm(forms.Form):
    def __init__(self):
        self.fields['has_code']= forms.CharField(widget= forms.CheckboxInput())
Run Code Online (Sandbox Code Playgroud)

我想要的是当我发布表单时,我应该将帖子数据作为{'has_code':True}

forms django http-post

3
推荐指数
1
解决办法
1896
查看次数

Rails:获取具有相同名称的 multipart/form-data POST 请求参数

我无法影响协议的网站向我发送 POST 请求,其中多个参数具有相同的名称“t”。

这是我的request.raw_post:

--===13978193024621189109088990673===
Content-Disposition: form-data; name="t"
Content-Type: text/plain; charset=UTF-8

thevalue1
--===13978193024621189109088990673===
Content-Disposition: form-data; name="t"
Content-Type: text/plain; charset=UTF-8

thevalue2
--===13978193024621189109088990673===
Content-Disposition: form-data; name="t"
Content-Type: text/plain; charset=UTF-8

thevalue3
--===13978193024621189109088990673===
Content-Disposition: form-data; name="t"
Content-Type: text/plain; charset=UTF-8

thevalue4
--===13978193024621189109088990673===
Content-Disposition: form-data; name="t"
Content-Type: text/plain; charset=UTF-8

thevalue5
--===13978193024621189109088990673===
Content-Disposition: form-data; name="t"
Content-Type: text/plain; charset=UTF-8

thevalue6
Run Code Online (Sandbox Code Playgroud)

标准params集合只列出最后一个参数。

如何获取所有值?

重现此请求的方法是:

<form action="/updateinfo" method="post" enctype="multipart/form-data">
  <input type="text" name="t" value="thevalue1"><br>
  <input type="text" name="t" value="thevalue2"><br>
  <input type="text" name="t" value="thevalue3"><br>
  <input type="text" name="t" value="thevalue4"><br>
  <input …
Run Code Online (Sandbox Code Playgroud)

parameters parsing ruby-on-rails http-post

3
推荐指数
1
解决办法
7056
查看次数

我可以拥有的最大“POST”大小是多少?

对不起,如果这是一个重复的问题,但我找不到任何关于我关注的实质性信息。

目前,我有一个 Java-GWT 应用程序,它调用部署在应用程序引擎上的 python 脚本。它们通过 REST 进行通信。

那么我可以发送到部署脚本的 Google App Engine 的 POST 方法的最大大小是多少?

限制是否与链接中指定的相同:https : //groups.google.com/forum/# ! topic/google-appengine-java/5V9W9ibq4Ns。如果我们使用 Python 而不是 Java,也会有任何区别。

post google-app-engine http http-post python-2.7

3
推荐指数
1
解决办法
2324
查看次数

TypeError:无法读取未定义的属性"post"

嗨,我只是想使用一个简单的函数,http post将我的日期发布到一个页面.我希望服务器能够获取我发布的日期.

import { Component, OnInit } from '@angular/core';
import { MarginServcies } from '../../services/MarginService';
import { Response } from '@angular/http';
import { Http} from '@angular/http';
//import { Ng2SmartTableModule, LocalDataSource } from 'ng2-smart-table';


@Component({
    selector: 'margin',
    template: require('./margin.component.html')
})


export class MarginComponent implements OnInit {
    public http: Http;
    public MarginList = [];
    public date: string;
    public userdate: string;
    pad(i: number) {
        return i < 10 ? '0' + i : i;
    }
    onClick($event: any, userdate) {
        userdate = this.date;
        //console.log(this.date); …
Run Code Online (Sandbox Code Playgroud)

http-post typescript angular

3
推荐指数
1
解决办法
1万
查看次数