1

I want to pass one value through ajax by taking the values from jQuery. But I am using link so I have problems taking the value. I tried the following,

<a id="addpa" class="ActionPopup" href="http://localhost:49951/admin/assignhome/Add?sPId=7">Add</a>

Jquery Code:

var spId = $("#addpa").prop("href"); // Here i am getting a whole Url
var thequerystring = getParameterByName("sPId"); 

The result is showing undefined. How to take the value of sPId? Give me ideas..

mplungjan
  • 169,008
  • 28
  • 173
  • 236
PoliDev
  • 1,408
  • 9
  • 24
  • 45

1 Answers1

3

How to take the value of sPId?

Try using String.prototype.split() , Array.prototype.pop()

var spId = $("#addpa").prop("href").split(/=/).pop();
mplungjan
  • 169,008
  • 28
  • 173
  • 236
guest271314
  • 1
  • 15
  • 104
  • 177