简体   繁体   中英

jQuery .load() to a different page

I have a form on a pop up window called add_weekly_job.php and once it has been successfully submitted I want to load content from diary_weekly_load.php to a div on another page diary_weekly.php.

I know how to use .load() to get content from a different page but not how to send content to a different page or even if it can be done?

  $(".add_weekly_job_submit").on( "click", function (){
      var week_start = $('input[name=week_start]').val();
      var user_id = $('input[name=created_by]').val();
      alert(user_id);
      jQuery.ajax({
          type: "POST",
          url: "ajax/diaries_change_ajax.php",
          dataType: "json",
          data: $('#add_job_form').serialize(),
          success: function(response){
              if(response.success === 'success'){
                  $("#diary").load("ajax/diary_weekly_load.php?week_start="+week_start+"&user="+user_id);
              }
          },
      });
  });

The button add_weekly_job_submit is displayed on the pop up page add_weekly_job.php and the page I want the content to load on is diary_weekly.php

The reason I am using a pop up page rather than just a javascript pop up is because the user needs to be able keep it open if they navigate away from diary_weekly.php

I finally managed it by using

if(response.success === 'success'){
    window.opener.$("#diary").load("ajax/diary_weekly_load.php?week_start="+week_start+"&user="+user_id);
    window.close();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM