SEARCH YOUR SOLUTION HERE  

brief walk through AJAX??

daniweb users, i would like a brief walk through on AJAX if you'll can, i already looked through the post and didn't find what i was looking for, i would like to know how to refresh evertying on a web page but the header, which contains the navigation bar that way only the content info is refreshed,

Posted On: Sunday 25th of November 2012 09:03:51 PM Total Views:  304
View Complete with Replies




Related Messages:

How to get unique ID for each textbox when its generating through for   (198 Views)
This is the code I have. i want unique Id for each text box(id="messageText"). PLEASE GIVE IDEA. As due to same ID of the text box the JS function is not showing the proper result and the characterleft count is not decreasing automatically. --------------------------------------------------------------------------------------------- currentSelectionOnPage = ; function charsleft() { theInputBox = document.getElementById('messageText'); theCountBox = document.getElementById('charsLeft'); var currentChars = theInputBox.value.length; theCountBox.value = Math.max((maxChars - currentChars),0); if(currentChars > maxChars) { theInputBox.value = theInputBox.value.substring(0,maxChars); } } for( int i = 0; i < 10; i++ ) { if(competencyAreaDTO.getComment()) { String commentSelKey = new String(String.valueOf(counter+1)+"_COMMENTS"); String prevCommetSelection = new String(); int charLeft =(int) new Integer(500); if(userSelection.get(commentSelKey) != null) { prevCommetSelection = (String) userSelection.get(commentSelKey); charLeft = 500 - (prevCommetSelection.length()); }    Characters Left   }
Sort through variable names   (101 Views)
, this is my first time posting on this forum. Hope you could help me. I am a beginner when it comes to Javascript. Here is my first stumbling block in this language. The code that works if(x==1) { p1.value="x"; } if(x==2) { p2.value="x"; } if(x==3) { p3.value="x"; } if(x==4) { p4.value="x"; } if(x==5) { p5.value="x"; } if(x==6) { p6.value="x"; } if(x==7) { p7.value="x"; } if(x==8) { p8.value="x"; } if(x==9) { p9.value="x"; } the code I hope that would work but didn't p[x].value="x"; As you can see, I want to use just one line to set x as a value of one of the p named variables, but I just can't seem to make it work. Help
Looping through XML with Javascript   (244 Views)
! I've searched around trying to find an accurate topic for my problem, but nothing came up that was helpful. I'm trying to loop through an XML file and display the contents on a HTML page. My problem is the loop is displaying the first set of data and on the 2nd run through says the node is undefined. Here is a snippet of the XML node I'm looping through: 8-Bit MP3 Player Self-explanatory. I made a custom MP3 player with an 8 bit retro design two.jpg http://www.*********.ca/mp3player/ Looping through every tag and popping the data on the page. Here is my function that loops through the XML once the data is loaded. (I'm using the jQuery library): function loadData(xml){ alert('data loaded'); var items=xml.getElementsByTagName('item').length; var title, desc, thumb, swf; //alert(items); for(i=0; i < items; i++){ //alert('in the loop'); title = xml.getElementsByTagName("title")[i].childNodes[i].nodeValue; desc = xml.getElementsByTagName("desc")[i].childNodes[i].nodeValue; thumb = xml.getElementsByTagName("thumb")[i].childNodes[i].nodeValue; swf = xml.getElementsByTagName("swf")[i].childNodes[i].nodeValue; $('#portfolioContent').append('' + title + '' + '' + desc + '' + '' + swf + ''); } } I think there is an issue with the variable I'm setting in the getElementsByTagName("title")[i] selector, but I'm unsure.
Format E-mail sent through javascript contact us form   (194 Views)
I am making a contact us form, when the user will submit the form it will send the entered information via email to a already specified E-mail address ( using mailto: option), Now everything is working fine, But I can not figure out how format the enterd information into a nicely formatted E-mail. I know that can be done using PHP, but it suppose to be made from javascript (Client requirment). Thank you.
Addition through javascript   (95 Views)
hi, I wanted to know how can we use arithmatic operations like addition, multiplication of two variables from two input boxes, and the answer will appear in the third input box. actually u can say i have little or no idea of javascript and i have to implement this arithmatic opertaion in an application of mine, so can u plz help me with it. one more i wanted to know whether the page gets refreshed when we perform this javascript operation. regards, kauhsik
POSTing data to PHP through Javascript Button   (77 Views)
I ordinarily submit data to my PHP script through a POST action that redirects the page, but I'd like to get Javascript to handle that so I stay on the same page.
Looping through an array property   (112 Views)
Hi , I am trying yo loop through an array property that is multi-valued and so the condition is if that property has what the value specified then alert with a message saying hello.. The other idea is kinda complex that is to check using RegExp... Here is the code.. var array = new Array(); array.fruit= "banana, apple"; array.vegies ="cucumber, carrot, tomatos, potatos"; array.drinks = "coke, pepsi"; var pep = "pepsi"; var getVal; outerloop: for(var obj in array){ getVal = array[obj]; println(obj + " : " + getVal); if ( obj.hasOwnProperty( "pepsi") ){ here is the problem alert("hello"); break outerloop; } } Cheers,
Pass parameter through js, to AJAX, to php page.   (136 Views)
Hi all, I'm sorry if the thread title doesn't make much sense; I'm quite new to AJAX (well, to web programming as a whole. I'm more of a SQL/client-server developer). Anyway, I'm having some trouble getting some code to work. What I'm doing is I am dynamically loading a list of "products" into an with an onclick event. The onclick will call a javascript function that makes use of AJAX to pass it into a PHP page to return the result. Here's my code (snippets. Let me know if you need more infomation): //This is the code that dynamically builds the product list. //This builds the string just fine and it displays fine on the page. //From what I can tell, this code should be fine. $tmpParse = $tmpParse . "Price: $" . $cost . ""; //This is the loadItem function in my .js function loadItem(productID) { var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { var JSONObject = JSON.parse(xmlhttp.responseText); document.getElementById("title").innerHTML = JSONObject.title; document.getElementById("byline").innerHTML=JSONObject.byline; document.getElementById("body").innerHTML=JSONObject.msgbody; } } var url="itemDetails.php"; url = url+"productID="+productID; msg = url; xmlhttp.open("GET",url,true); xmlhttp.send(null); } //And finally, this is the itemDetails PHP page where I extract the parameter:
How to read XML through Javascript   (90 Views)
I'm new with AJAX and I'm trying to read an XML file with Javascript. It's supposed to display an alert message but it's not. What's wrong with my code
unset session variable through ajax PHP   (152 Views)
Hi all, i need help in unsetting session variables through ajax
printing text on image through js   (121 Views)
, if i have to print some text over a image in particular location of image can i do it with javascript actually i have a check(image) but i want to print name , amount over that image but i want it be in write place of check image thnx in adv, BTW: writing an elegant routine to print the amount in words in the available space is a moderately challenging task for a quiet morning.
Setting default value through javascript   (247 Views)
i want to change the default value of dropdown list to 0 i.e selected index value shud become 0 when press the cancel button so that watever i selected previously is removed here is the javsacript function CloseDiv() { var control = document.getElementById("divReqStages"); control.style.visibility = "hidden"; var control1 = document.getElementById('DDLReqStages').selectedIndex; control1.value='0'; } here s asp.net code
iterate through an anonymous array?   (106 Views)
Is it possible to iterate through an anonymous array of strings with a for loop Here's what I'm trying to do: for ( i in ['country', 'city', 'state'] ) { doSomethingWithString(i); } What I want is the string, but what I'm getting is the index number of the array, which I can't use because the array isn't named. Thank you. -- -- Ghodmode
Problem passing email address through AJAX   (136 Views)
I am facing problems passing an email address to a php file through AJAX. The code I am using is pretty basic but I can't seem to get it to work. Could anyone help me understand what's going wrong I amd pretty new to Ajax (about 2 days old) so please forgive me if this seems pretty lame. function emailchk () { if (!document.getElementById("email").value) { document.getElementById("emailmsg").innerHTML = " "; } else { url = "emailchk.phpemail=" + document.getElementById("email").value; if (window.XMLHttpRequest) { xhr = new XMLHttpRequest(); } else { if (window.ActiveXObject) { try { xhr = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { } } } if (xhr) { xhr.onreadystatechange = showEmailContents; xhr.open("GET", url, true); xhr.send(null); } else { alert("Sorry, but I couldn't create an XMLHttpRequest"); } return false; } } function showEmailContents() { if (xhr.readyState == 4) { if (xhr.status == 200) { var outMsg = xhr.responseText; } else { var outMsg = "There was a problem with the request " + xhr.status; } document.getElementById("emailmsg").innerHTML = outMsg; if (outMsg == "Email already exists") { document.getElementById("validate").value = "no"; } else { document.getElementById("validate").value = "yes"; } } } The PHP file is also pretty basic...
how to get values through javascript and pasted in?   (145 Views)
Hi all, 1] I have to create one html file which uses javascript. 2] HTML page can be accessed by user and can fill the; [A] Folder path along with file name 3] There will be a button, after click on that a batch file [already present but without any values] will run with new values provided by javascript. 4] Through that batch file i will process XML to HTML conversion. 5] After completion of batch 1 message should be given as "Process Over" Purpose of this - User will not interact directly with batch file. He/ She will just paste the path and file name and click on button. Rest of the things will done in background. User can see only output, without interrupting the actual process. My HTML looks like below, Welcome to this project Wel-come Please enter file name here Please enter folder path here Please suggest is this possible if yes how it can be done
Refreshing a Page with PHP through Ajax   (76 Views)
, Right now I'm working on a login system for my site. The user enters their info, the info is sent to the php page through ajax, the php checks if the input fields are empty and checks if the info is correct. If fields are empty or the info is wrong, it updates a div layer with an error message telling them what is wrong. My problem though is if the user enters correct info. If the user enters correct info I want the main page (index.php) to be refreshed (This is the page with the original form on it). Anyone know how to do this This is my javascript: function createRequestObject() { var ro; var browser = navigator.appName; if(browser == "Microsoft Internet Explorer"){ ro = new ActiveXObject("Microsoft.XMLHTTP"); }else{ ro = new XMLHttpRequest(); } return ro; } var http = createRequestObject(); function login() { var Username = document.Login.loginUsername.value; var Password = document.Login.loginPassword.value; var URL = document.Login.URL.value; var params = 'Username='+Username+'&Password='+Password+'&URL='+URL+''; document.Login.loginBtn.disabled=true; document.Login.loginBtn.value='Validating'; http.open('POST', 'loginUser.php', true); http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); http.setRequestHeader("Content-length", params.length); http.setRequestHeader("Connection", "close"); http.onreadystatechange = handleResponse; http.send(params); } function handleResponse() { if(http.readyState == 4){ var response = http.responseText; var update = new Array(); if(response.indexOf('|' != -1)) { update = response.split('|'); document.getElementById(update[0]).innerHTML = update[1]; document.Login.loginBtn.disabled=false; document.Login.loginBtn.value='Try Again'; } } } Here is my PHP File:
Looping through listbox items   (115 Views)
Hi friends I am new to javascript I came across to use that in my application Can anyone please tel me, how can i loop through the items in a listbox Thank you all,
looping through json notation   (81 Views)
Hi all, I wonder if you can help me again with some more json. I have this json fragment: cars_data={ "haveAlook": { "xmlns:fo": "http://www.w3.org/1999/XSL/Format", "xmlns:inlineData": "Lookup", "CategoryAttributes": { "attOne": "MyattOne", "attTwo": "MyattTwo", "attThree": "MyattThree", "attFour": "MyattFour", "attFive": "MyattFive", "attSix": "MyattSix", "attSeven": "MyattSeven" }, "TheThumbnails": { "thumb1": "first.png", "thumb2": "second.png", "thumb3": "third.png", "thumb4": "fourth.png", "thumb5": "fifth.png", "thumb6": "sixth.png", "thumb7": "seventh.png", "thumb8": "eight.png", "thumb9": "ninth.png", "thumb10": "tenth.png", "thumb11": "eleventh.png", "thumb12": "twelfth.png", "thumb13": "thirteenth.png", "thumb14": "fourteenth.png", "thumb15": "fifteenth.png", "thumb16": "sixteenth.png", "thumb17": "seventeenth.png" }, ... What I am trying to achieve here is to get data from this json fragment using jquery/javascript and insert this data in my html (I know that if you haven't javascript enabled you can't do it and bla bla, but that's the way we have decide to implement this). The data I want to get out of the json are the thumbnail images. I have 17 images there that I want to place within the tag in my html. The json fragment is in my script where the rest of the functions are. Here's the html in question: ... Small family Large family MPV 4x4 Sport ... Right, I have spent the whole day today trying to find a solution but I couldn't crack this. My main script attempts are the following: 1)This works in that it insert an image inside every , except that it insert always the same image "thumb1". What I need instead is to insert a different image in every . I should loop through the images in the json notation but I am not sure how to do it. $(document).ready(function(){ init_compare_range(); }); var cars_data; function init_compare_range(){ cars_data={rest of the json as above} insertImages(); } //insert car thumbnails but at the moment I can only insert 1 image and not all the thumbnails as I would like $(document).ready(function(){ init_compare_range(); }); var cars_data; function init_compare_range(){ cars_data={rest of the json as above} insertImages(); } function insertCars(){ var car=cars_data.haveAlook.TheThumbnails.thumb1; console.log(car); $(".vehicle_row a").each(function(){ $(this).html(''); }); } 2)here because car is an object I thought I could access it with an array notation. Obviously, knowing absolutely nothing about json, I was wrong. $(document).ready(function(){ init_compare_range(); }); var cars_data; function init_compare_range(){ cars_data={rest of the json as above} insertImages(); } //insert car thumbnails function insertImages(){ var car=cars_data.haveAlook.TheThumbnails; var index=i; console.log($(car[0])); $(".vehicle_row a").each(function(){ $(this).html(''); }); } 3) SO I thought to myself, ok let's use a proper array: $(document).ready(function(){ init_compare_range(); }); var cars_data; function init_compare_range(){ cars_data={rest of the json as above} insertImages(); } //insert car thumbnails function insertImages(){ var car= new Array("cars_data.haveAlook.TheThumbnails.thumb1", "cars_data.haveAlook.TheThumbnails.thumb2", "cars_data.haveAlook.TheThumbnails.thumb3"); console.log(car[0]); $(".vehicle_row a").each(function(){ $(this).html(''); }); } But obviously I was wrong, the console returns the string in the array element as it should. So, how do I do this please ANy help at all I need is a way to make sure that all the images in json gets within my tags.
Split function and looping through predefined class?   (101 Views)
, I was wondering what the string.split() does. And another question is that I want to loop through the class like Math and find out what functions are defined in it.But, I was not too sure how to that. I tried a couple of things but they unfortunately didn't work. Thank you..
Send Json object through ajax   (117 Views)
Im having difficulty getting my form contents to send to my php page using ajax, jquery and json. The results just doesnt want to show. My javascript, where I create the JSON object and try to send it through to the php page: var JSONobj; var JSONstr; function createJSON(){ JSONobj = { firstname : $('#firstname').val(), surname : $('#surname').val(), age : $('#age').val(), email : $('#email').val() }; JSONstr = JSON.stringify(JSONobj); } $(document).ready(function() { $('#submit').click(function(e){ e.preventDefault(); createJSON(); $.post("save.php", {data:JSONstr}, function(result){ alert(result);}, "json"); }); }); The php page: What should happen is the firstname should be alerted. But the alert box doesnt even show and I find no errors using firebug...