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
  • 155,085
  • 27
  • 166
  • 222
PoliDev
  • 1,348
  • 9
  • 23
  • 44

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
  • 155,085
  • 27
  • 166
  • 222
guest271314
  • 1
  • 12
  • 91
  • 170