Jump to content

Order of calling the js files


phpmady

Recommended Posts

Hi guys,

 

I have a file where the calling to the function fails, when the order is like this

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir=rtl>
<HEAD>
<TITLE>sms</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" >
<meta http-equiv="Content-Language" content="ar-sa">
<META name="author" content="Technology Skills">
<META name="copyright" content="Technology Skills-2009 ">
<META name="keywords" content="">
<META name="description" content="">
<LINK href="css/general1.css" type=text/css rel=stylesheet>



<script type="text/javascript" src="js/ajax_check_send_one.js" language="javascript"></script>
<script type="text/javascript" src="js/ajax_user_operate.js" language="javascript"></script>        


</HEAD>
<BODY>

<!-- START BLOCK : sms p -->
<form  NAME="SMForm" method="post" action="sms.php?do=send_one">



    <div class="row">
        <span class="label">رقم الجوال<span class="men">*</span></span>
        <span class="formw">
        <input type="text" class="textbox_forms required" name="SMS_Mobile" size="50" onblur="chkUser(this.value);" dir="ltr"></span>
    </div>
    
    
    
    <div class="row" id="user_already"></div>
    
    <div class="row1"><span class="label">Format Message</span>
        <span class="formw" dir="">
        <select name="F_ID">
        <!-- START BLOCK : format_msg -->
        <option value="{F_ID}" {for_selected}>{F_Title}</option>
        <!-- END BLOCK : format_msg -->
        </select>
        </span>
    </div>
    
    
    
    
    
    <div class="row">
        <input type="button" onclick="ajax_check_sendone();" value="SUBMIT" />
    </div>
    
    
    <div class="row" id="Notice"></div>



</form> 

<!-- END BLOCK : sms p -->



</BODY>
</HTML>

 

I have called 2 js functions for ajax calling..

 

 

<script type="text/javascript" src="js/ajax_user_operate.js" language="javascript"></script>       

<script type="text/javascript" src="js/ajax_check_send_one.js" language="javascript"></script>

 

its not working ...

 

but when i have replace like

 

<script type="text/javascript" src="js/ajax_check_send_one.js" language="javascript"></script>

<script type="text/javascript" src="js/ajax_user_operate.js" language="javascript"></script>       

 

 

its working for the above call..

 

Whats the logic in this...

 

Please give me some inputs,

 

Thanks,

 

 

 

 

 

 

Link to comment
Share on other sites

How are we expected to give an accurate answer when we can't see the code? At best speculation, it would be that something in "ajax_user_operate.js" relies on "ajax_check_send_one.js".

 

 

File: ajax_user_operate.js

 

// JavaScript Document

var xmlhttp;
//function namechange(name_fieldvalue)

function chkUser(mobile_number)
{

xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Your browser does not support XMLHTTP!");
  return;
  }
var url="ajax_user_operate.php";
url=url+"?mobile_number="+mobile_number;
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function stateChanged()
{
if (xmlhttp.readyState==4)
  {

  document.getElementById("user_already").innerHTML=xmlhttp.responseText;
  }
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}

 

 

File:ajax_check_sendone.js

 

// JavaScript Document

 

var xmlhttp1;

//function namechange(name_fieldvalue)

 

function ajax_check_sendone()

{

 

 

alert("hi1");

//get the total points needed

 

 

 

var format_id = document.getElementById("gt").value;

var balance_points = document.getElementById("Balance_Points").value;

 

alert(format_id);

alert(balance_points);

 

xmlhttp1=GetXmlHttpObject();

if (xmlhttp1==null)

  {

  alert ("Your browser does not support XMLHTTP!");

  return;

  }

var url1="ajax_check_send_one.php";

url1=url1+"?format_id="+format_id;

url1=url1+"&balance_points="+balance_points;

 

alert(url1);

 

xmlhttp1.onreadystatechange=stateChanged;

xmlhttp1.open("GET",url1,true);

xmlhttp1.send(null);

}

 

function stateChanged()

{

if (xmlhttp1.readyState==4)

  {

 

  document.getElementById("notice").innerHTML=xmlhttp1.responseText;

  }

}

 

function GetXmlHttpObject()

{

if (window.XMLHttpRequest)

  {

  // code for IE7+, Firefox, Chrome, Opera, Safari

  return new XMLHttpRequest();

  }

if (window.ActiveXObject)

  {

  // code for IE6, IE5

  return new ActiveXObject("Microsoft.XMLHTTP");

  }

return null;

}

 

This is the code am using, Please correct me, if am wrong

 

Thanks,

 

 

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.