论坛首页 Web前端技术论坛

jquery ajax跨域访问的问题

浏览 2164 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2012-12-10  
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
    $(document).ready(function() {
        $("#btnSubmit").click(function() {
            Search();
        });
    });
    function Search() {
        $.ajax({
            type: "POST",
            url: "http://118.122.89.217:8808/ANBOSS/productView.c?do=queryProduct",
            data: {barCode: $("#barCode").val()},
			dataType: 'jsonp', 
			jsonp: 'jsoncallback', 
			timeout: '10000',
            beforeSend:function(){
				$("#msg").html("正在查询中,请稍候.....");
            },
            success:function(json){
				$("#msg").html('<h3>您好,您查询的产品结果如下:</h3><div class=hot>'+json+'</div><h3>感谢您对爱恋珠宝的支持!</h3>');
            },
            error:function(){
				$("#msg").html("抱歉,您输入的产品条形编码(证书号)有误,请重新核对您的产品编号。");
            }
        });
    }
</script>


type:POST
dataType:jsonp

我在网上看到说 'jsonp'可以支持跨域访问  就修改了成上面这种 但是一直执行不了。

可以输入“1”测试!
   发表时间:2012-12-11  
jsonp的实现方式限定了它只能发GET请求
0 请登录后投票
   发表时间:2012-12-11   最后修改:2012-12-11

http://www.cssass.com/blog/index.php/2012/1317.html

0 请登录后投票
论坛首页 Web前端技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics