Problem integrating Ajax with Django code

0

I was making a code which reads a weather forecast and shows the value on a web platform, and the value is updated after a certain amount of time without needing to refresh the page. I was trying to accomplish in django, but I'm having trouble integrating the codes

   <script type="text/javascript">
    function update(){
    setTimeout( function(){
    $.ajax({
  type: "GET",
  url: '',
  data{
  'weather': weather,
  dataType : "json",
  data = weather,
  sucess: function(json){

        $('weather').html(json);
  }
  }

})
},3000);};

No views.py:

           def home(request):
             if (request.is_ajax()):
             print(1)
             return JsonResponse({'lio_weather': get_from_api()})
            context = {'api_weather': get_from_api()}
             return render(request,'app/video.html',context)

url.py

    urlpatterns = [
        path('', views.home, name='home'),
    ]

It's the first time I'm running a web application, so these are doubts. Thank you for your attention.

    
asked by anonymous 18.09.2018 / 02:58

0 answers