473,659 Members | 2,965 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

IE10 doesn't post variables in post array with Ajax calls

omerbutt
638 Contributor
Hi i am working on a module and my code is working fine on all browser except when using IE10 my ajax requests does not post data inthe $_POST array here is my javascript code
Expand|Select|Wrap|Line Numbers
  1. var objXMLHttp;
  2.  
  3. function GetXmlHttpObject(){
  4.     objXMLHttp=null;
  5.     try{
  6.         // Firefox, Opera 8.0+, Safari
  7.         objXMLHttp=new XMLHttpRequest();
  8.     }catch (e){
  9.         // Internet Explorer
  10.         try{
  11.             objXMLHttp=new ActiveXObject("Msxml2.XMLHTTP");
  12.         }
  13.         catch (e){
  14.             try{
  15.                 objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
  16.             }
  17.             catch (e){
  18.                 jAlert('Please upgrade your browser','<span>No AJAX Support</span>');
  19.                 return false;
  20.             }
  21.         }
  22.     }
  23.     return objXMLHttp;
  24. }
  25. var xmlCheckoutExb;
  26.     function checkout_exhibitor(){
  27.         var str=getFormsExb();
  28.         str=str+'&num='+Math.floor(Math.random()*1);
  29.         var url=base_url+"exhibitor/save_conference_registration";
  30.         xmlCheckoutExb=GetXmlHttpObject();
  31.         if(xmlCheckoutExb==null){
  32.             alert("Please upgrade your browser");
  33.             return;
  34.         }else{
  35.             xmlCheckoutExb.onreadystatechange=$checkout_exhibitor;
  36.             xmlCheckoutExb.open("POST",url,true);
  37.             xmlCheckoutExb.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
  38.             xmlCheckoutExb.setRequestHeader("Content-length", str.length.toString());
  39.             xmlCheckoutExb.setRequestHeader("Connection", "close");
  40.             xmlCheckoutExb.send(str);
  41.         }
  42.     }
  43.     function $checkout_exhibitor(){
  44.         if(xmlCheckoutExb.readyState==4){
  45.             alert('4');
  46.             if(xmlCheckoutExb.status==200){
  47.                 alert('200');
  48.                 var responses=xmlCheckoutExb.responseText.split("|");
  49.                 var switching_option='';
  50.  
  51.                 var str            =    responses[1];
  52.                 var status        =    responses[0];
  53.                 var insert_id    =    responses[2];
  54.  
  55.                  switching_option=jQuery("#payment_optins_div :checked").val();
  56.  
  57.                 if(status=="Done"){
  58.                     if(switching_option=='paypal'){
  59.                         location.replace("https://www.sandbox.paypal.com/cgi-bin/webscr"+"?"+str);
  60.                     }else{
  61.                         /*TOUQEER USE THIS PORTION*/
  62.                         window.location = base_url+"exhibitor/order_pdf/"+insert_id;
  63.                     }
  64.                 }else{
  65.                     alert(xmlCheckoutExb.responseText);
  66.                 }
  67.             }
  68.         }
  69.     }
  70.     function getFormsExb(){
  71.         var fobj=document.forms["registration"];
  72.         var str="";
  73.         var cmd="";
  74.         var val="";
  75.  
  76.         for(var i=0; i<=fobj.elements.length-1;i++){
  77.             switch(fobj.elements[i].type){
  78.                 case "text":
  79.                         if(fobj.elements[i].value!=''){
  80.                         str += fobj.elements[i].id + "=" + fobj.elements[i].value + "&";
  81.                         }
  82.                 break;
  83.  
  84.                 case "hidden":
  85.                     str += fobj.elements[i].id + "=" + fobj.elements[i].value + "&";
  86.                 break;
  87.  
  88.                 case "radio":
  89.                     if(fobj.elements[i].checked){
  90.                         str += fobj.elements[i].id + "=" + fobj.elements[i].value+ "&";
  91.                     }
  92.                 break;
  93.  
  94.                 case "checkbox":
  95.                     if(fobj.elements[i].checked){
  96.                         str += fobj.elements[i].name + "=" + fobj.elements[i].value+ "&";
  97.                     }
  98.                 break;
  99.                 case "textarea":
  100.                     if(fobj.elements[i].value!=''){
  101.                         str += fobj.elements[i].name + "=" + fobj.elements[i].value + "&";
  102.                     }
  103.                 break;
  104.             }
  105.         }
  106.         str = str.substr(0,(str.length - 1));
  107.         return encodeURI(str);
  108.     }
  109.  
when i alert the post array on the php page which i am calling in the ajax call it simply shows empty array , can any one help.
regards,
Omer Aslam
Apr 16 '13 #1
9 6756
Dormilich
8,658 Recognized Expert Moderator Expert
have you checked, whether the data are in any of the other superglobal arrays ($_GET, $_REQUEST, etc.)?

Im not sure about IE10s dev tools, but maybe you can find anything there about the issued network traffic.
Apr 16 '13 #2
omerbutt
638 Contributor
yes i have checked it if turn the request to GET and pass null in xmlRequestObjec t.send() then the data is passed into the GET array and is visible, i used the developer tools but it didnt showed any error through which i cold backtrack the problem there are several people facing the issue when i googled it
regards,
Omer Aslam
Apr 16 '13 #3
Dormilich
8,658 Recognized Expert Moderator Expert
have you changed the Content-Type header for the POST request accordingly?

I meant the dev tools to check, what exactly you send an receive.
Apr 16 '13 #4
omerbutt
638 Contributor
i collect all the fields via javascript using
Expand|Select|Wrap|Line Numbers
  1. getFormsExb() 
  2.  
which returns a concatenated string of the field's values and names which is then sent to the php page via AJAX call using method POST and passing the string in xmlHttp.send(st r);
when i start monitoring the traffic on the IE dev tool it shows me nothing in the request body although i try to alert the string that is about to be posted via ajax and it has all the values available , i temporarily changed the method from POST to get and changed the php code to GET to make it work but POST isnt working yet still trying to figure out
here is the detail for the network capturing tab
REQUEST HEADERS
Key Value
Request POST /content/save_conference _registration HTTP/1.1
Accept */*
Content-Type application/x-www-form-urlencoded; charset=UTF-8
Referer http://www.wcpa.nxb/content/annual_conference
Accept-Language en-US
Accept-Encoding gzip, deflate
User-Agent Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)
Host www.wcpa.nxb
Content-Length 0
DNT 1
Connection Keep-Alive
Cache-Control no-cache
Cookie PHPSESSID=7r19l 8de9elbdmqmm9su 6dquu6
REQUEST BODY
NO DATA TO VIEW
RESPONSE HEADERS
Key Value
Response HTTP/1.1 200 OK
Date Wed, 17 Apr 2013 08:29:14 GMT
Server Apache/2.2.21 (Win32) mod_ssl/2.2.21 OpenSSL/1.0.0e PHP/5.3.8 mod_perl/2.0.4 Perl/v5.10.1
X-Powered-By PHP/5.3.8
Expires Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma no-cache
Content-Length 10
Keep-Alive timeout=5, max=82
Connection Keep-Alive
Content-Type text/html
RESPONSE BODY
Array
(
)
INITIATOR
Property Value
Stage Document Processing
Element XMLHttpRequest
Action Processing
Document ID 0
Frame ID 0
Frame URL http://www.wcpa.nxb/content/annual_conference
Apr 17 '13 #5
Dormilich
8,658 Recognized Expert Moderator Expert
when i start monitoring the traffic on the IE dev tool it shows me nothing in the request body although i try to alert the string that is about to be posted via ajax and it has all the values available
at least we know now that the problem is not withing PHP, but within IE.
Apr 17 '13 #6
Dormilich
8,658 Recognized Expert Moderator Expert
interseting read: sending AJAX with form data directly (https://developer.mozilla.org/en-US/...rmData_Objects)
Apr 17 '13 #7
omerbutt
638 Contributor
sorry dormilich but i could not get anything here that could help me out still wandering around and not getting to the real cause....changi ng everthing to GET starts working but not with POST.
regards,
Omer Aslam
Apr 18 '13 #8
omerbutt
638 Contributor
aah i figured out the main part which had the problem it was the main function through which i was generating the new xmlHtttpObject
Expand|Select|Wrap|Line Numbers
  1. function GetXmlHttpObject(){
  2.  objXMLHttp=null;
  3.     try{
  4.         // Firefox, Opera 8.0+, Safari
  5.         objXMLHttp=new XMLHttpRequest();
  6.     }catch (e){
  7.         // Internet Explorer
  8.         try{
  9.             objXMLHttp=new ActiveXObject("Msxml2.XMLHTTP");
  10.         }
  11.         catch (e){
  12.             try{
  13.                 objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
  14.             }
  15.             catch (e){
  16.                 jAlert('Please upgrade your browser','<span>No AJAX Support</span>');
  17.                 return false;
  18.             }
  19.         }
  20.     }
  21.     return objXMLHttp;
  22. }
  23.  
i replaced this old style try catch to the following
Expand|Select|Wrap|Line Numbers
  1. function GetXmlHttpObject(){
  2.     var activexmodes=["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"] //activeX versions to check for in IE
  3.     if (window.ActiveXObject){ //Test for support for ActiveXObject in IE first (as XMLHttpRequest in IE7 is broken)
  4.         for (var i=0; i<activexmodes.length; i++){
  5.             try{
  6.                 return new ActiveXObject(activexmodes[i])
  7.             }
  8.             catch(e){
  9.             //suppress error
  10.             }
  11.         }
  12.     }else if (window.XMLHttpRequest) // if Mozilla, Safari etc
  13.         return new XMLHttpRequest()
  14.     else
  15.         return false
  16. }
  17.  
and everything started working perfect :D, i still cant figure out after comparing the 2 methods that what could be the thing that was causing not to pass the data through POST method.
regards,
Omer Aslam
Apr 18 '13 #9
Dormilich
8,658 Recognized Expert Moderator Expert
i still cant figure out after comparing the 2 methods that what could be the thing that was causing not to pass the data through POST method.
then the first question would be, which object (ActiveX, XHR) your browser did use. And we all know that an implemented object does not necessarily be error free.
Apr 20 '13 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

13
1813
by: Marcus | last post by:
Hi All, I was wondering if there is a way to ensure that when submitting forms and using POST vars, the page sending the form resides on the same server as the destination page specified in the form action. For example, if I have a page on a live server that accepts POST variables, I can simply create a second page on my local host or any other server for that matter that lets me send any values I want for these POST variables.
5
5340
by: Kit | last post by:
Hi there, I am recoding a website, and I want to add a generic footer to each page, using an included file with PHP snippets. Part of that footer would be a link to validate the page using the W3C's validation service. The code currently looks like this: <code> <a href="http://validator.w3.org/check?uri=<?php echo "http://www.athenatest.org" . $PHP_SELF; ?>" >
3
2072
by: Vic Spainhower | last post by:
Hello, I have an HTML table that is being constructed from a MySQL table and displays a form that includes a check box on 1 of the fields on the form for each record. I have included in this PHP program a javascript routine called sorttable.js which is something I found on the internet for sorting tables and works quite well. The HTML table includes a check box on each record so the user can select certain records for passing to the...
2
8102
by: Aaron | last post by:
I'm trying to pull data from a website and read it into a file the I can parse. I've done the before to site without post variables but I can seem to get my statments to work with the post. Can someone help me out? below is the code I have so far. Thank in advance... $url="www.somesitethatneedspostvariables.com"; $postdata = http_build_query( array( 'postvarname1' ='value1',
17
11858
by: Arjen | last post by:
Hi, I want to reload 2 divs at one click. Ive tried: <a href = "javascript:void(0);" onclick="show('ajaxrequest.php?action=removefield','div1');show('ajaxrequest.php?action=reloaddiv2','div2')">verwijderen</a> While both seperate actions work they dont when I put them together. Anyone know how to fix this ? My ajax.js with funcition show
5
6154
by: steve.chambers | last post by:
I'm sure this q must have been asked before but I'm really struggling to find the answer anywhere so have finally given up and will consult the usenet community - hopefully there's someone out there who's seen it all before and can help me out! I have a webpage which needs to make some function calls after the page has loaded - won't go into details surfice to say here is a code fragment: function addLoadEvent(func) { var oldonload =...
3
3945
by: dhsieh | last post by:
I am trying out nested AJAX calls for the first time, but I seem to have hit a snag. The code snippet is the outer AJAX call and a function, it gathers information about a company. As we get towards the bottom of the onComplete function, there is a call to doGetAddressContacts(), which accepts an address ID. This then returns a list of contacts at that address. What I am trying to do is for each address that it retrieves and outputs, as it...
7
4597
by: =?Utf-8?B?QmlsbHkgWmhhbmc=?= | last post by:
我们现在遇到一个问题,通过wcf创建的webservice,选择windows service作为宿主,采用java作为客户端调用成功,但是无法使用asp.net ajax调用。 我们参考了http://msdn.microsoft.com/zh-cn/library/bb410780.aspx的资料,并且下载了相应的sample code,但是发现这些sample基本上都需要在iis上部署一个svc文件,但是根据当前业务需求,我们无法部署iis服务器。...
1
3078
by: kidalex | last post by:
So, I have a summary page of some stuff that gets updated through AJAX calls back to the server every 15 seconds or so. However, if you leave that page up for a few hours - it'll slow down the computer and eventually crash it with the following message: "Internet Explorer: out of memory on line..." I know AJAX got some memory leaks problems but this is not that much stuff that gets refershed ( a few table rows ).
1
3500
by: andwan0 | last post by:
I have a legacy classic ASP website with lots of classic AJAX (many ASP files specially made for processing AJAX requests). We are slowly migrating the website to ASP.NET 2.0 and developing under Visual Web Developer 2005/2008. I notice VWD doesn't debug ASP files. Since we are still migrating a very large website, we are mixing ASP.NET code with classic ASP (ASP.NET pages making AJAX calls to classic ASP pages). In Visual Studio 2003.NET...
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
8335
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8747
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8528
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8627
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6179
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2752
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.