/    Sign up×
Community /Pin to ProfileBookmark

ajax – get params

hello.

i have a Div tag with calendar in it.. and below calendar there is a YEAR/MONTH select menu + submit button..
i submit form using ajax after that i take params this way

[CODE]
$(document).ready(function() {
$(‘#target’).click(function() {
var month =document.getElementById(‘GetMonth’).value;
var year =document.getElementById(‘GetYear’).value;
var UserSelectedDate =”month=”+month+”&year=”+year;
var url=’http://’+ siteurl +’/cal.php?’+UserSelectedDate;//
});
[/CODE]

as u see above i use cal.php file which gets params and displays month and year selected by user.. everything is just fine and works perfect…

the only thing i do not like in this is that if someone types [url]http://somesite/cal.php[/url] he/she will be able to display that file..

i know there is nothing bad with that, because user won`t be able to Harme me by doing so…

anyway i wanted to use index.php?+params instead of seperate cal.php file..

but when i do use index.php?params..

and then want to reload div.. using

[CODE]
document.getElementById(“calendar”).innerHTML=objXMLHttp.responseText
[/CODE]

the content of Calendar DIV is replaced with all of the content index.php generates…

is there any way to force calendar div not to load all of the content of index.php instead just get +params and reload calendar?

i tryied to be Clear you to understant what i want to do.
thanks a lot in advance

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@kubasMar 01.2010 — you can set params when sending ajax request

and then in index php echo/output only what you need

index.php something like this
[CODE]
if(isset($_GET['ajax'])){
... ajax request ...
} else {
... other ...
}
[/CODE]


you can write also script only for ajax requests.

Hope this helps,

Kuba
×

Success!

Help @LogicOpinion spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...