问题描述
- 通过ajax jsonp跨域传值
-
我想把这个
var itemData = new Object();
itemData = {"dollercost":dollerCost,"rmbcost":rmbCost,"contnum20GP":$("#contNum20GP").html(),"contnum40GP":$("#contNum40GP").html(),"contnum40HQ":$("#contNum40HQ").html(),
"QYPortEN":detailPrice.QYPortEN,"MDPortEN":detailPrice.MDPortEN,"line":detailPrice.line,"ShipEN":detailPrice.ShipEN,"Voyage":detailPrice.Voyage,"ShipDate":detailPrice.ShipDate,
"PortArea":detailPrice.PortArea,"MiddlePortEN":detailPrice.MiddlePortEN};
itemDatal里边的值通过ajax的json传到Test.html页面,求高手指教啊
解决方案
原生JAVASCRIPT 用Ajax 跨域传值
var xhr = new XMLHttpRequest()
function sear(){
var cont = document.getElementsByTagName('input')[0].value;
var url = 'http://ajax.googleapis.com/ajax/servi......<br/><strong>答案就在这里:</strong><a target='_blank' rel='nofollow' href='http://blog.csdn.net/a519640026/article/details/8822994'>Ajax 跨域传值之 jsonp</a><br/>
解决方案二:
你test.html静态页?这样你代码无法获取ajax传递的参数,即使是get传参。
如果是重写过的动态页需要将itemData转为json格式的字符串,然后用jsonp传过去(get)
var itemData = new Object();
//...
itemData=encodeURIComponent(JSON.stringify(itemData));
var img=new Image();
img.src='http://xxxxx.xxxx/test.html?data='+itemData;///传参
时间: 2024-09-19 03:55:39