kamiar3001
kamiar3001

Reputation: 2676

Send some parameters to the same page using jquery.ajax

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 ?

Upvotes: 1

Views: 1232

Answers (1)

Nick Craver
Nick Craver

Reputation: 630419

$.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 }});

Upvotes: 1

Related Questions