views:

12

answers:

1

hi folks
I use jquery and it gives me error : "Microsoft JScript runtime error: 'url' is null or not an object"
when I use "$.ajax(window.location.href");" inside window.location.href is like this :
"http://localaddress/mypage.aspx?id=2"
How I can solve it ?

+1  A: 

$.ajax() takes an object with options, like this:

$.ajax({ url: window.location.href });

If you just want to fetch a URL, use $.get() like this:

$.get(window.location.href);

It's one of the $.ajax() shorthand methods, if you want to send parameters, it looks like this:

$.get("mypage.aspx", { id: 2 });
//or long-hand
$.ajax({ url: "mypage.aspx", data: { id: 2 }});
Nick Craver