Reputation: 163
I have went through many samples to have a variable inside quotes..But that doesnt help my case..it is strange in my case..have a look at it..
Var x='http://www.xyzftp/myservice/service1.svc'
Var y='/logincheck'
Now i want to have it inside a single quoted string like
'http://www.xyzftp/myservice/service1.svc/logincheck'
UPDATE:
I have a file named domainname.xml
I get the value http://www.xyzftp/myservice/service1.svc from that file.Now i need to concatenate /logincheck with it and pass as an URL to an ajax call...
Thats my specific need guys !!
Any ideas friends ???
Upvotes: 1
Views: 4868
Reputation: 12739
There is no difference between a variable declared with single quotes vs. one declared with double quotes:
var a = 'test';
var b = "test";
a === b;
> true
To join your two strings, just concatenate them with a +
or concat()
:
var x='http://www.xyzftp/myservice/service1.svc';
var y='/logincheck';
var z = x + y; // concat with +
z;
> "http://www.xyzftp/myservice/service1.svc/logincheck"
// or
var z = x.concat(y); // concat with contact()
z;
> "http://www.xyzftp/myservice/service1.svc/logincheck"
Now, if we're all just misunderstanding your question, and what you are actually looking for is a string with single quotes as part of the string contents, here's how you can get that:
var x='http://www.xyzftp/myservice/service1.svc';
var y='/logincheck';
var z = "'" + x + y + "'"; // use double quotes as string delimiters
// or:
var z = '\'' + x + y + '\''; // use single quotes as delimiters and
// escape the single quote in the string
z;
> "'http://www.xyzftp/myservice/service1.svc/logincheck'"
Upvotes: 1
Reputation: 12712
var x = 'http://www.xyzftp/myservice/service1.svc';
var y = '/logincheck';
var combined = x + y;
Upvotes: 0
Reputation: 1802
do like this:
Var x='http://www.xyzftp/myservice/service1.svc'
Var y='/logincheck'
x= x+""+y; or simply x= x+y;
you will get string: 'http://www.xyzftp/myservice/service1.svc/logincheck'
Upvotes: 0