Cross-domain jQuery.getJSON from a Node.JS (using express) server does not work in Internet Explorer

后端 未结 2 1752
星月不相逢
星月不相逢 2020-12-18 08:57

This is an annoying problem, and I don\'t suppose that it\'s only IE that has this problem. Basically I have a Node.js server, from which I am making cross-domain calls to g

2条回答
  •  青春惊慌失措
    2020-12-18 09:25

    The following code shows how to handle the GET request (using express) and how to wrap the JSON response using the callback given:

    app.get('/foo', function(req, res){ 
      res.header('Content-Type', 'application/json');
      res.header('Charset', 'utf-8') 
      res.send(req.query.callback + '({"something": "rather", "more": "pork", "tua": "tara"});'); 
    });
    

提交回复
热议问题