简体   繁体   中英

How do I send a JavaScript variable to another page when using JQuery UI

Hey guys So I have the following:

$(document).ready(function () {
    $(".NotesAccessor").click(function () {
       var notes_name = $(this).parent().prev().prev().prev().prev().prev().prev().prev().prev().html();
      run();
    });
});

This get a name for when someone clicks on the attribute and from there goes to this function that opens and starts the dialog:

function run(){
    var url = '/pcg/popups/grabnotes.php';
    showUrlInDialog(url);
}

function showUrlInDialog(url)
    {
      var tag = $("#dialog-container");
      $.ajax({
        url: url,
        success: function(data) {
          tag.html(data).dialog
          ({
              width: '100%',
                modal: true
          }).dialog('open');
        }
      });
    }


function update()
    {
        $.ajax({
        url: '/PCG/termsofservice/accepted.php',
        success: function() {
            $("#dialog-container").dialog( 'close' );

            }
          });

    }

function closeNotes()
    {
        $("#dialog-container").dialog( 'close' );
    }

So give the variable notes_name over to a variable in PHP in the file that is opened up in the Jquery UI? Or do I have to send it over? I am not to certain on what to do.

David

jQuery's $.ajax() function has a method for passing data:

$.ajax({
  type: "POST",
  url: '/PCG/termsofservice/accepted.php',
  data: { /* data object goes here */ },
  success: function() {
      $("#dialog-container").dialog( 'close' );
  },
  dataType: dataType
});

Docs: http://api.jquery.com/jQuery.ajax/

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