Jump to content

Javascript problem its "unknown runtime error"


chillininvt

Recommended Posts

I am developing an ajax application and it works great only there way no way to inform my users that processing was actually taking place. I decided that if I had the javascript write to a div element then we can ask the user if they are submitting the correct data by checking the value of the input accessing it using the value of the id. Anyhow here are 2 functions where the error is occuring in internet explorer.

 

function ajaxprofilecheck(data){
 inputcon = escape(document.getElementById(data).value);
 document.getElementById('profilestatusview').innerHTML = 'Do you want to change '+data+' to '+inputcon+' ?<br><input name="check" type="submit" id="check" value="yes" onClick="testandgo(\'yes\');"><input name="formdata" type="hidden" id="formdata" value="'+data+'" ><input name="querycheck" type="submit" id="querycheck" value="no" onClick="testandgo(\'no\');">';

}
function testandgo(tru){
  if(tru == "no"){
	  document.getElementById('profilestatusview').innerHTML = 'No Data was updated.';
	  
  }else{
	   var data = document.getElementById('formdata').value;
      ajaxprofilecleard(data);
	  document.getElementById('profilestatusview').innerHTML = 'Your Profile Was Updated.';
  }

}

 

You see what it does is when a user clicks on a button it will invoke. ajaxprofilecheck() function. What this does is write into div the data that they wish to input and also passing back, the value of data into a hidden input in the page. Then When you click on the submit button from the status window it will invoke the test and go function. If the test and go function is set to yes then it will make the ajax request. Which this script works like a charm in firefox as my statusview method of verifying the data is great. It keeps the page moving quickly and users on the page longer. The only problem is in ie when you click on yes make the ajax request I get an unknown runtime error. I have the same script making other ajax request with different variables so I dont believe the error is in the ajax code or the back end php script. I think for some reson ie may not be able to grab the value of formdata from the element. This element is written in with javascript. Fire for appears to access this value just fine.

Link to comment
Share on other sites

I figured out what the problem was I was not making my handle server response a reference to the object but rather assigning the value of the function to anther variable and just exectuting it. Anyhow I am new to javascript but I can see that the solution to my problem I will need to set up a global variable or reference another value. I need to send a variable to the handleserverresponse function but I cannot do this if accessing it by reference. Because I have to make reference to the functcion like this

 xmlHttp.onreadystatechange = handleServerProfileEdit;

What I need to do essentially is give the function a variable

handleServerProfileEdit(data);

Like this but if you simply add the variable like that it display an unknown runtime error it will have the ability to read the variable within the function but when referencing the Document Object Module ie is throwing me some errors. So how would I be able to declare another variable within the new object. Can I create another function within this function to grab the value of the variable that I need. Essentiall what happens is when a button is clicked it send a yes and a know then adds a value to an input. So long as I can get the value of this variable within my handle server response function than it will work fine. I do not want this variable available to anyother functions other than the 2 functions that need to use it.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.