jquery live and callbacks via wcf services
Posted
by vondip
on Stack Overflow
See other posts from Stack Overflow
or by vondip
Published on 2010-04-20T22:02:45Z
Indexed on
2010/04/20
22:13 UTC
Read the original article
Hit count: 282
Hi all,
I am writing a web app with asp.net, c# and jquery. Most of the time I'm writing dynamic html to the browser and using different web services to get the content needed.
My call to the service:
function WriteProducts(currentIndex, selectedCategoryId, callback) {
var d = new Date();
MyAppServices.GetProducts(selectedCategoryId, currentIndex, 8,
d.getTime().toString(), callback, function func() {
alert('failure');
});
}
The request usually gets translated to this (using firebug I monitored it):
http://localhost:8080/MyApp/MyAppServices.svc/GetProducts?categoryId=0&fromIndex=0&toIndex=8&randomNumber=%221271800014441%22
The problem starts when part of the html controls dynamically rendered need to respond to click events. This is when I start using jquery's live method:
$('.filter').live('click', function(event) {
WriteProducts(0, selectedCategoryId, PopulateDivs);
});
Now from some reason, the request passed to the server becomes this:
http://localhost:8080/MyApp/MyAppServices.svc/GetProducts?categoryId=**%2217%22**&fromIndex=0&toIndex=8&randomNumber=%221271799783355%22
where did these %22 come from? If I take them out, the request passes successfully. I have no idea who inserted these %22, but they are causing havoc here!
Guys, do you perhaps have a clue?
© Stack Overflow or respective owner