       window.location.reload()
     @confirm_delete () =>
       @learner_url = null
-      @save_to_server(null,"")
+      @save_to_server(null, "")
 
   save_to_server: (interactive_json, learner_url) ->
     return unless @put_url
+    # Do not send the same state to server over and over again.
+    return if JSON.stringify(interactive_json) == JSON.stringify(@saved_state)
+
     runSuccess = =>
+      @saved_state = interactive_json
       if @success_callback
         @success_callback()
       else
         @default_success
+
     if interactive_json is "nochange"
       runSuccess()
       return

          @save_to_server(interactive_json, @learner_url)
        else
          # wait a bit and try again:
          window.setTimeout () =>
            @save_to_server(interactive_json, @learner_url)
          ,
          500
      @iframePhone.addListener 'getAuthInfo', =>
        authInfo = { provider: @auth_provider, loggedIn: @logged_in}
        if @user_email?
          authInfo.email = @user_email
        @iframePhone.post('authInfo', authInfo)
      @iframePhone.addListener 'extendedSupport', (opts)=>
        if opts.reset?
          @should_show_delete = opts.reset
          if @has_saved_state
            if @should_show_delete
              @$delete_button.show()
            else
              @$delete_button.hide()

      if @put_url
        #Save interactive every 42 seconds just to be safe:
        window.setInterval (()=> @save()), 42 * 1000
      @iframePhone.post('getExtendedSupport')
      @iframePhone.post('getLearnerUrl')
      # TODO: There used to be a callback for model_did_load
      # hopefully this will work
      model_did_load()

    @iframePhone      = new iframePhone.ParentEndpoint(iframe, phone_answered)



  @default_success: ->

        if response['raw_data']
          interactive = JSON.parse(response['raw_data'])
          if interactive
            @saved_state = interactive
            @iframePhone.post({type: 'loadInteractive', content: interactive})
            @$delete_button.show() if @should_show_delete == null or @should_show_delete
      error: (jqxhr, status, error) =>
        @error("couldn't load interactive")

# Export constructor.
window.IFrameSaver = IFrameSaver

$(document).ready ->
