2 Replies - 1550 Views - Last Post: 24 December 2012 - 03:49 AM

#1 mckenzie1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 23-December 12

Popup window not closing on submit

Posted 24 December 2012 - 01:53 AM

Hi All

I have seen posts with similar topics, but not with exactly the same errors I am getting, so apologies if it's been answered somewhere else!!

I have a popup window which has 2 questions for the user in order to initiate a new listing in the database. What should happen is that on "submit", the window closes, the new listing is created and the user is redirected to the main edit_listing page. However, what is happening, is that although the database is being populated with the details in the background on "submit", the popup window is not closing and there is no redirection.

This is the same for IE, Chrome and Firefox.

<script type="text/javascript">
  $("#add_listing_form_button").click(function(){
   $("#add_listing_form").submit();
  });
  $("#add_listing_form").validate({
   meta: "validate",
   submitHandler: function(form) {
    $("#add_listing_form_button").attr("disabled", "true");
    $.post("{baseurl}/admin/ajax.php?action=ajax_add_listing", $("#add_listing_form").serialize(),
     function(data){
      if(data.error == "1")
      {
       $("#add_listing_form_button").attr("disabled", "false");
       alert(data.error_msg);
      }
      else
      {
       var listing_id = data.listing_id;
       $("#add_listing_form_button").attr("disabled", "false");
       $.fn.colorbox.close(); 
       window.location = "{baseurl}/admin/index.php?action=edit_listing&edit="+listing_id;
      }
     }
    ,"json");
    return false;
   }
  }); 
</script>


I have done a similar thing for adding a new user successfully and can't seem to figure out what is creating the error - It's likely a missing character somewhere and could do with another set of eyes on it!!

If I have missed anything please let me know - I'd like to say that this isn't my day job, so be gentle!!

Many thanks

Gavin

MOD EDIT: Added code tags. When posting code...USE CODE TAGS!!!

:code:

This post has been edited by JackOfAllTrades: 25 December 2012 - 04:56 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Popup window not closing on submit

#2 mckenzie1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 23-December 12

Re: Popup window not closing on submit

Posted 24 December 2012 - 03:40 AM

To add a little more to the above, if I remove "json" the window does close, however brings back an undefined listing_id and therefor the redirection goes to:

"{baseurl}/admin/index.php?action=edit_listing&edit=undefined"
Was This Post Helpful? 0
  • +
  • -

#3 mckenzie1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 23-December 12

Re: Popup window not closing on submit

Posted 24 December 2012 - 03:49 AM

I mentioned in the original post that another similar function is working ok - for reference, please see below:

<script type="text/javascript">
 $("#add_user_form").validate({
  meta: "validate",
  submitHandler: function(form) {
   $.post("ajax.php?action=ajax_add_user", $("#add_user_form").serialize(),
    function(data){
     if(data.error == "1")
     {
      alert(data.error_msg);
     }
     else
     {
      var user_id = data.user_id;
      $.fn.colorbox.close(); 
      window.location = "index.php?action=edit_user&user_id="+user_id;
     }
    }
   ,"json");
   return false;
  }
 }); 
 
</script>


MOD EDIT: Added code tags. When posting code...USE CODE TAGS!!!

:code:

This post has been edited by JackOfAllTrades: 25 December 2012 - 04:57 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1