I have been googling and reading MDN, and trying different things, and still can not get it to work.Is anyone able to help with this?Why does it cause such a problem?
js = '''
var xhr = new XMLHttpRequest();
xhr.open('POST', 'https://www.ti.com.cn/occservices/v2/ti/addtocart', false);
xhr.setRequestHeader('Content-type', 'application/json');
xhr.send('{"cartRequestList":[{"packageOption":null,"opnId":"%s","quantity":"%d","tiAddtoCartSource":"store-pdp","dienCode":"","year":"","week":"","batchCode":"","pcrCode":"","sparam":""}],"currency":"CNY"}');
return xhr.response;''' % (product['opn'], product['num'])
js = js.replace(" ", "").replace("\n", "")
resp = driver.execute_script(js)
return resp