Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-07-2006, 04:51 PM   PM User | #1
sir pannels
Regular Coder

 
Join Date: Jun 2002
Posts: 905
Thanks: 23
Thanked 5 Times in 5 Posts
sir pannels is an unknown quantity at this point
XMLHTTP post Request - Page Headers?

hi all,

When using xmlhttp request for POST as you may know you can have a form target to somefile.php .asp, whatever) and put return false in the onsubmit tag also so the form does not actually submit, yet somefile.php still runs.

That somefile.php just returns a value, the ajax then puts that value in a div..

Problem I have is I do not understand why you need to set content type of somefile.php. Strictly speaking, is it even being called in the browser for display?

The reason I ask is because I set the content type of the file to text/plain and internet explorer just asks me if I want to download or save somefile.php when I submit the form. In opera, it seems to fully submit the form and instead of returning value to the <div> it actually sends me to an entire new page with the value on.

Not really a php question more and ajax/js one so hope i get away with it here.

anyone have any thoughts?
cheers,
sir p
sir pannels is offline   Reply With Quote
Old 12-07-2006, 05:09 PM   PM User | #2
A1ien51
Senior Coder

 
A1ien51's Avatar
 
Join Date: Jun 2002
Location: Between DC and Baltimore In a Cave
Posts: 2,717
Thanks: 1
Thanked 94 Times in 88 Posts
A1ien51 will become famous soon enough
When you make a post you should set:
req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

You really just need to set the content type when we are using XML, using responseText really does not care about the type.

Eric
__________________
Tech Author [Ajax In Action, JavaScript: Visual Blueprint]
A1ien51 is offline   Reply With Quote
Old 12-08-2006, 02:07 PM   PM User | #3
sir pannels
Regular Coder

 
Join Date: Jun 2002
Posts: 905
Thanks: 23
Thanked 5 Times in 5 Posts
sir pannels is an unknown quantity at this point
hi eric,

thanks for that.

I have set the type for the request but on the server side script you also need to set the content type

Im gonna post in the PHP forum thin its more of that

cheers for you time
sir pannels is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:00 PM.


Advertisement
Log in to turn off these ads.