相关疑难解决方法(0)

HTTPS查询字符串是否安全?

我正在创建一个使用HTTPS的安全的基于Web的API; 但是,如果我允许用​​户使用查询字符串配置它(包括发送密码)这也是安全的,还是应该通过POST强制它?

ssl https query-string

331
推荐指数
8
解决办法
9万
查看次数

将数据发布到JsonP

是否可以将数据发布到JsonP?或者所有数据都必须作为GET请求在查询字符串中传递?

我有很多需要发送到服务的数据,跨域,并且它太大而无法通过查询字符串发送

有什么方法可以解决这个问题?

javascript ajax jquery json jsonp

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

JSONP请求错误处理

我正在制作ajax jsonp请求,但失败错误处理不起作用.如果请求是404或500,它将无法处理错误.

我一直在寻找答案,但找不到任何答案.http://code.google.com/p/jquery-jsonp/似乎有一个解决方案,但我找不到任何关于如何使用它的示例.

function authenticate(user, pass) {       
    $.ajax ({
        type: "POST",
        url: "url",
        dataType: 'jsonp',
        async: false,
        //json object to sent to the authentication url
        data: {"u": userid, "p": pass},

        success: function (data) {
            //successful authentication here
            console.log(data);
        },
        error: function(XHR, textStatus, errorThrown) {
            alert("error: " + textStatus);
            alert("error: " + errorThrown);
        }
    })
}
Run Code Online (Sandbox Code Playgroud)

ajax error-handling jquery json jsonp

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

当通过本地apache发送请求时,POST转换为GET

我正在尝试使用以下代码发送帖子请求.但请求是作为GET请求而不是POST.如何解决这个问题.

$.ajax({
    url: 'https://www.exampleurl.com',
    method: 'POST',
    headers: {"Access-Control-Allow-Origin": true},
    data: {url:'bla',call:"trans"}
    dataType: 'jsonp',
    success: function(data){
      console.log('succes: '+data);
    }
  });
Run Code Online (Sandbox Code Playgroud)

这是我得到的错误XMLHttpRequest无法加载https://example.com.对预检请求的响应未通过访问控制检查:请求的资源上不存在"Access-Control-Allow-Origin"标头.原产地" :HTTP //本地主机,因此"是不允许访问.响应具有HTTP状态代码401.

当删除标题Access-Control-Allow-Origin时,我收到404错误

javascript jquery

5
推荐指数
1
解决办法
670
查看次数

服务参考的正确URL是什么?

我有两个项目,一个是WCF服务,它在文本框中说出文本/句子.

public class Service1 : IService1
{
    public string RunTts(string text)
    {
        using (SpeechSynthesizer synth = new SpeechSynthesizer())
        {
            // Configure the audio output. 
            synth.SetOutputToDefaultAudioDevice();
            synth.Speak(text);
            return "";
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

然后我在第二个项目的_Layout.cshtml页面中用ajax调用它,它是asp.net mvc.

<script type="text/javascript">
    function ttsFunction() {
        serviceUrl = "Service1.svc/RunTts";

        $.ajax({
            type: "POST",
            url: serviceUrl,
            data: '{"text": "' + $('#speak').val() + '"}',
            contentType: "text/xml; charset=utf-8",
            dataType: "text/xml",
            error: function (xhr,status,error) {
                console.log("Status: " + status); // got "error"
                console.log("Error: " + error);   // got "Not Found"
                console.log("xhr: " + …
Run Code Online (Sandbox Code Playgroud)

wcf jquery asp.net-mvc-4

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

我的ajax调用总是发送get请求而不是post.为什么?

$.ajax({
        type:"post",
        url: server_url,
        dataType: "jsonp",
        jsonpCallback: callback,
        data:req_json,
        cache: false,
        timeout: 60000,
        success: succeeded,
        error: got_error
    });
Run Code Online (Sandbox Code Playgroud)

我正在尝试上面的代码来发送POST requset但是在服务器端总是只接收GET请求,任何人都可以告诉我为什么会发生这种情况?在此先感谢.. server_url就像http://ip:8007

ajax jquery node.js

0
推荐指数
1
解决办法
2336
查看次数