0

I have set a global variable from the data coming from a jquery. and save that data in a global variable as :

 var window.globalname = data;  // variable value set in another ajax call

i want to send this global variable through another ajax call then how should i write ??
i have written :

type:'POST', // ajax call
url:'url'
data: {name="globalname"} or data :{name="$globalname"} 

i want to know how to write this data ??

1
  • 1
    Eh... data: {name: window.globalname} Commented Apr 12, 2014 at 15:29

1 Answer 1

3

First of all, (almost) NEVER use global variables in JavaScript. You pollute your global scope.

As to your question, try the following:

$.ajax({
  type: 'POST',
  url: 'url',
  data: {name: window.globalname},
});
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.