Neshnt Wsm
Neshnt Wsm

Reputation: 3

How to pass javascript variable in jquery .load

I'm using jquery's .load function to load a page in a container , but I need to pass some parameters with the url, javascript variables hold the value of the parameter

    var data = "xyz";
$("#toggleText").load("inner/playlist.php",{name:data});

Upvotes: 0

Views: 3478

Answers (1)

whiteagle
whiteagle

Reputation: 1158

its always good idea to use quotes for the param names.

$("#toggleText").load("inner/playlist.php",{'name':data});

also, try to put the callback function to check it it actually does anything:

$("#toggleText").load("inner/playlist.php",{'name':data}, function(response, status, xhr) {
if (status == "error") {
    alert("Error: " + xhr.status + " " + xhr.statusText);
  }
});

Upvotes: 1

Related Questions