Сделайте свою жизнь проще и используйте Moment.js пример кода:
var beginDateTime = moment()
.format('DD-MM-YYYY HH:mm')
.toString();
// Now will print 30-06-2015 17:55
console.log(beginDateTime);
пытаюсь указать в ответе MIME-тип «text / plain». или просто удалите расширение ".json" из URL-адреса (например, попробуйте .txt или .js)
Отбросьте .json и установите тип содержимого как text / html. IE не знает, какой тип файла вы его отправляете, поэтому предлагает скачать. Он знает, что делать с text / html :)
Not sure if you found a solution, but I had a similar problem where IE tried to download any JS responses. To fix it, I had to ensure that format.html appears above format.js in the response block:
def index
# ...
respond_to do |format|
# html must be above js, otherwise IE will try to download the JS
format.html
format.js
end
end
Hope this helps.