Hey all Im have trouble passing this jquery functions results thru an ajax call.
I want this function:
to pass as string, any ideas?
Shouldn't the function already pass a string? jQuery ATTR
My guess here, since the selector you used is a class(and no reference HTML code was shown), it returns multiple elements or no element, and you were expecting only one(?). But then it resulted to getting value from an unexpected element with an href attribute or an element without an href.
Have you seen the value returned by
$('.sidebar_bookmark_linkrel1').attr('href')? what it "undefined", relative path, or an absolute?
One way to check it is by
alert($('.sidebar_bookmark_linkrel1').attr('href')), let's start from there.
If it's ok for you, can you please post the part of you JS code where you send the data. It'll be best if you post the JS part where you process the
$('.sidebar_bookmark_linkrel1').attr('href') up to sending your data through AJAX. How's do you format the data anyway?
You can encode the sent URL like this,
var encodedHREF; encodedHREF = encodeURIComponent(yourHREFValue);
before sending it, to make it more friendly. Then you can just decode it like this:
$decodedURL = ""; $decodedURL = urldecode($varibleToYourHREF);
and process it from there.
I think I solved the problem well for the mean time. Set up a new attribute within the href html tag, and use jquery to read that in. As of now, cakephp seems to be passing it as an int no problem. So Ive been able to use that in my database calls once the user clicks on said link . If it stays working... cakephp hasnt been nice to me or my component lol.