jquery问题xhr.send((s.hasContent&& s.data)|| null);

时间:2013-03-26 13:29:59

标签: javascript jquery ajax

我正在通过jquery执行简单的post请求,并在localhost上从中读取数据。

如果我通过localhost访问该文件,我的脚本工作正常,但如果我通过在控制台上双击它来访问该文件,它会说我200红色文本,我没有得到任何响应。我的文件名是send.html,它通过jquery发送数据。 我的代码是

<script src="http://code.jquery.com/jquery-1.9.1.js"></script> 
<script>
$(document).ready(function (){  
                    var counter =1 , array_counter =0;
                    var picture_id_array=new Array(6);
                    picture_id_array[1] = new Array(3);
                    $.ajax({   
                        type: "POST",
                        data : $(this).serialize(),
                        cache: false, 
                        url: "http://localhost/CI/index.php/page/id/1",   
                        success: function(data){
                            var obj = jQuery.parseJSON(data);
                       var json = $.parseJSON(data);
                       $(json).each(function(i,val){
                            $.each(val,function(k,v){
                             console.log(k+" : "+ v);    
                            }
                          });
                  });

它告诉我关于jquery中的这一行会导致错误

 // Do send the request
// This may raise an exception which is actually
// handled in jQuery.ajax (so no try/catch here)
xhr.send( ( s.hasContent && s.data ) || null );

我尝试了一种解决方案,即推送数据类型:JSONP,但它没有给我结果。

0 个答案:

没有答案