相关疑难解决方法(0)

jquery ajax readystate 0 responsetext status 0 statustext error

我收到以下错误:jquery ajax readystate 0 responsetext status 0 statustext error给它时: url(http://www.tutorialspoint.com/prototype/prototype_ajax_response.htm)但是当我url(localhost:""/embparse_page)在我的localhost上给它时,它工作正常.

我曾尝试使用我在Google搜索中找到的标题,我也使用beforeSend:""了它,但它仍然无效.

我认为主要问题是:XMLHttpRequest cannot load http://www.tutorialspoint.com/prototype/prototype_ajax_response.htm. Origin "local server" is not allowed by Access-Control-Allow-Origin.但我不明白.

任何人都可以向我解释这个问题,因为我对此很陌生.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns:ng="http://angularjs.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <meta Access-Control-Allow-Origin="*" />
    <title>Page Parsing</title>
    <script type="text/javascript" src="/js/jquery-1.9.1.min.js"></script>
    <script>
    getit=function(){
        jQuery.support.cors = true;
        $.ajax({
            type:"GET",
            url:"http://www.tutorialspoint.com/prototype/prototype_ajax_response.htm",
            dataType:"html",
            crossDomain:true,
            beforeSend: function(xhr) {
                xhr.overrideMimeType('text/plain;charset=UTF-8');
            },
            success:function(XMLHttpRequest,jqXHR ,data) {
                //alert(data.title);
                var starttitl=data.lastIndexOf('<title>');
                var endtitl=data.lastIndexOf('</title>'); …
Run Code Online (Sandbox Code Playgroud)

javascript ajax jquery

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

在readystate 0,status 0和statusText错误上跟踪AJAX错误

我读完所有这些类似的问题:1,2,3,4,56.但我需要调试更多.

所有这些问题都表明问题是由跨域政策引起的并且e.preventDefault()解决了问题.但我怀疑这可以打破其他一些事情,所以我需要确定.

在我的网站上,我有一个每天被发射15k次的操作.当用户访问网页时,我的javascript文件会检查一个元素.如果元素存在,则进行AJAX调用.

$(document).ready(function() {

    // I do something here

    if ($('#mydiv').length !== 0) {

       var startTime = new Date().getTime();        

       $.ajax({
           type: "POST",
           url: "/mypage",
           success: function (data) {
               // I do something here
           },
           timeout: 20000,
           error: function(r, s, e) {
               var elapsedTime = (new Date().getTime() - startTime );
               var string = "readyState: "+r.readyState+", status: "+r.status+", statusText: "+r.statusText+", responseText: "+r.responseText+", textStatus: "+s+", error: "+e +", …
Run Code Online (Sandbox Code Playgroud)

javascript ajax jquery

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

jQuery Ajax POST不成功

我无法使用jquery的ajax功能成功发布.

运行页面的http://localhost:9999URL是,目标(Web服务)的URL是http://localhost:8080.没有端口不相同,它们分别是9999和8080.

下面是请求和jquery ajax代码.

请求:

OPTIONS /profile/set_member HTTP/1.1
Host: localhost:8080
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Origin: http://localhost:9999
Access-Control-Request-Method: POST
Run Code Online (Sandbox Code Playgroud)

jQuery ajax代码:

$.ajax({ 
        type: "POST", url: "http://localhost:8080/profile/set_member", 
        contentType: "application/json", data: member, 
        error: function(){ alert('Update failed!'); }, 
        processData: false, 
        success: function(){ alert('Update successful!'); }
});
Run Code Online (Sandbox Code Playgroud)

ajax jquery post

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

标签 统计

ajax ×3

jquery ×3

javascript ×2

post ×1