JavaScript - I Have 3 Qs About Web-service/ajax(1,2) And Syntax Meaning(3)
I have 3 Qs about ajax(1,2) and syntax meaning(3):
1- I want to appear a list of urls from a db table to browser, with their newest Google PAGE RANK every time appear in the webpage, and this rank saved auto to database along with previous.... google provides any web service for this? tell me URLs? I found difficulty contact google... 2- Do you know any internet web service (programming) that you input a Russian word, and get (true or 1) if valid, or (false or 0) if not valid word? 3- what mean the in file attached statements to html main file? script.js?x=5 or style.css?p=5 or xmlfile.xml?x=777. Similar Tutorials0 down vote favorite I have been struggling with this for some time.. I searched around but didnt get a solution yet. This is only an issue on production server. In my development environment, everything works just fine. I am using JQuery/Ajax to update product information based on product's Color attribute. for example, a product has A and B color, the price for color A is different from color B. When user choose different color, the price information is updated as well. What I did is to first add a javascript function: function updateProductVariant() { var myval = jQuery("#<%=colorDropDownList.ClientID%>").val(); jQuery.ajax({ type: "POST", url: "/Products.aspx/GetVariantInfoById", data: "{variantId:'" + myval + "'}", contentType: "application/json; charset=utf-8", dataType: "json", success: function (response) { var obj = jQuery.parseJSON(response.d); jQuery("#<%=lblStockAvailablity.ClientID%>").text(obj.StockMessage); jQuery(".price .productPrice").text(obj.CurrentPrice); jQuery(".price .oldProductPrice").text(obj.OldPrice); } }); } Then I can register the dropdown list's 'onclick' event point to function 'updateProductVariant' GetVariantInfoById is a Web method in the codebehind, its also very straightforward: [WebMethod] public static string GetVariantInfoById(string variantId) { int id = Convert.ToInt32(variantId); ProductVariant productVariant = IoC.Resolve<IProductService>().GetProductVariantById(id); string stockMessage = productVariant.FormatStockMessage(); StringBuilder oBuilder = new StringBuilder(); oBuilder.Append("{"); oBuilder.AppendFormat(@"""{0}"":""{1}"",", "StockMessage", stockMessage); oBuilder.AppendFormat(@"""{0}"":""{1}"",", "OldPrice", PriceHelper.FormatPrice(productVariant.OldPrice)); oBuilder.AppendFormat(@"""{0}"":""{1}""", "CurrentPrice", PriceHelper.FormatPrice(productVariant.Price)); oBuilder.Append("}"); return oBuilder.ToString(); } All these works fine on my local box, but if i upload to the production server, catching the traffic using fiddler, /Products.aspx/GetVariantInfoById becomes a 302 Object moved Object moved to here. On my local box, HTTP/1.1 200 OK Server: ASP.NET Development Server/10.0.0.0 Date: Thu, 03 Mar 2011 09:00:08 GMT X-AspNet-Version: 4.0.30319 Cache-Control: private, max-age=0 Content-Type: application/json; charset=utf-8 Content-Length: 117 Connection: Close But when deployed on the host, it becomes HTTP/1.1 302 Found Proxy-Connection: Keep-Alive Connection: Keep-Alive Content-Length: 186 Via: 1.1 ADV-TMG-01 Date: Thu, 03 Mar 2011 08:59:12 GMT Location: http://www.pocomaru.com/Products.asp...d/default.aspx Server: Microsoft-IIS/7.0 X-Powered-By: ASP.NET then of course, then it returns 500 error title>Unknown web method GetVariantInfoById/default.aspx. Parameter name: methodName Can someone please take a look? I think its some configuration in the production server which automatically redirects my webservice call to some other URL, but since the product server is out of my control, i am seeking a local fix for this. Thanks for the help! This prbl. appears only in IE: Code: l2 = obj.parentNode.getElementsByTagName("select")[0].value; --> object does not support this property or method Code: var l2 = obj.parentNode.getElementsByTagName("select")[0].value; --> OK explanation needed. hello .. I want know what is the mean of these symbol : || {} thanks .. the HTML code: Code: <ul id="ul1"> <li>1111</li> <li>2222</li> </ul> <div id="div1"></div> the javascript code: Code: var oDiv=document.getElementById('div1'); oDiv.style.left=getPos(this).left+this.offsetWidth+'px'; oDiv.style.top=getPos(this).top+'px'; function getPos(obj){ var aPos={left: null, top: null}; while(obj) { aPos.left+=obj.offsetLeft; aPos.top+=obj.offsetTop; obj=obj.offsetParent; } return aPos; } why it write the while loop,and what's effection of the while loop obj=obj.offsetParent; what's this line meaning? function args() { return arguments; } don't know the "return arguments; "meaning. Quote: Traversal also aids developers in affecting the elements immediately surrounding an element that is being manipulated or otherwise utilized by a script. This can range from adding a class to parent elements to indicate activity to disabling all inactive form elements to any number of other useful tasks. can't understand the above,the paragraph is from a book.what the author want to tell.anyone helps.thank you, I'm troubleshooting some issues with menus closing and when I alert the return value from something like: Code: timer = setTimeout("closeMenu(id)",500); I get 2,3,4. It seems to increment. Does that just represent how many times the timeout code has been executed? Dear Sir, I have designed a mail service in java.In my compose page,i want to attach some excel files of text files and to send it.After sending i want to store it my database.Then how can i download or open that file after opening that recipient mail inbox. Regards Debasis Hi In C# I would attach the service reference http://www.anotherdomain.com/Service1.svc?wsdl then write myService MS = new myservice(); string[] s = MS.GetDates(); //return an array of string dates BUT can this be done with only Javascript/Jquery , where the service is on a different domain? Can you please tell me how or point me in the right direction Thanks for the help Hey all, I'm playing with a greasemonkey script and would like to provide geo-locating. The geolocation services I've found all require dev/api-key. A dev-key means I reveal my well-earned key, or an api-key usually means a server address... there would be none via a greasemonkey script. Any ideas for gathering geolocation services? Any links, tips, ideas welcome! Hello, I am writing a simple yahoo widget that consumes a web service. I tried by using soapclient.js Here is the code: Code: <action trigger="onLoad"> <!-- <text> <name>txtGroups</name> <color>#FFFFFF</color> <size>20</size> <vOffset>100</vOffset> <hOffset>150</hOffset> </text> include("soapclient.js"); mainWindow.visible = true; function getOffices() { var pl = new SOAPClientParameters(); pl.add("userId", preferences.User.value); pl.add("pwd", preferences.Password.value); SOAPClient.invoke("host:port/ReturnOffices/Config1?wsdl", "getOffices", pl, true, getOffices_callBack); } function getOffices_callBack(r) { txtGroups.data=r; } getOffices(); --> </action> I get error: Code: Your browser does not support XmlHttp Objects soapclient.js line 360 Can anybody please let me know what is the correct way to call a web service in javascript (onLoad)... Thanks Srinivas I was wondering if its possible to have javascript stop a service on my machine for instance terminal services and then start it again...Any help provided will be greatly appreciated
i have a web service at this url http://196.218.16.133/onlinereservat...p=HotelsSearch i use hotel search file with HotelSearch method and method will retrieve xml file contains the matched data. the varialbe that i made post with it is named : HotelData the data of the variable is a string file that contains an xml data like this Code: <HotelsParameters> <CityID>388</CityID> <UserName>admin</UserName> <UserPassword>admin</UserPassword> <DateFrom>4/12/2010</DateFrom> <DateTo>4/13/2010</DateTo> <NumberOfRooms>2</NumberOfRooms> <Room> <RoomSerial>1</RoomSerial> <Adults>1</Adults> <Child> <ChildSerial>1</ChildSerial> <ChildAge>5</ChildAge> </Child> </Room> <Room> <RoomSerial>2</RoomSerial> <Adults>2</Adults> <Child> <ChildSerial>1</ChildSerial> <ChildAge>8</ChildAge> </Child> </Room> <Room> <RoomSerial>3</RoomSerial> <Adults>3</Adults> <Child> </Child> </Room> <CurrencyID>162</CurrencyID> </HotelsParameters> i am trying to get the result by posting HotelData but i did not get the xml result file so can anyone help me my code is: Code: <script language="JavaScript"> function InitializeService() { service.useService("http://196.218.16.133/onlinereservation/service.asmx?WSDL", "HotelsSearch"); } var StrSearch; function GetAge() { StrSearch = document.DemoForm.StringSearch.value; service.HotelsSearchService.callService("HotelsSearch", StrYear); } function ShowResult() { alert(event.result.value); } </script> <form name="DemoForm"> Hotel Name : <input type="text" name="HotelData"/><br /> <button onclick="GetAge()">Get Age</button><br /> </form> the data in input filed is the previous xml file Hello javascript experts... I am following this blog on calling web service in javascript. I am getting syntax error, in my javascript... Code: <action trigger="onLoad"> <!-- mainWindow.visible = true; <script type="text/javascript" src="prototype.js"></script> <script type="text/javascript" src="ws.js"></script> <script type="text/javascript"> function getSalesXml(name, container) { var call = new WS.Call('<url to the wsdl>'); var nsuri = 'http://example'; var qn_op = new WS.QName('<functionName>',nsuri); var qn_op_resp = new WS.QName('sayHelloResponse',nsuri); call.invoke_rpc( qn_op, new Array( {name:'userId',value:<user>} {name:'pwd',value:<password>} ),null, function(call,envelope) { var ret = envelope.get_body().get_all_children()[0]. get_all_children()[0].get_value(); container.innerHTML = ret; $('soap').innerHTML = arguments[2].escapeHTML(); } ); } </script> --> </action> at line: Code: src="ws.js"></script> Can anybody correct this error..., Hi, I am writing JavaScript code that runs inside HTTP page, I need to make XMLHttpRequest to a REST web service. The service is running on the same site but it only accepts HTTPS. I tried to prefix the URL with https:// and Firefox rejected it as cross-site scripting attempt. It's not really cross site as I am calling the same site. I don't have an option to redirect the entire page to https. Is there a proper way to implement this request? Sergey p.s. (sorry if this is a dumb question, I am a JavaScript newbie) Hi I'm New to javascript how to Call WCF service using Javascript or Jquery in html page.(with out using Activex Objects) Hi, I'm using javascript in addition to a web service (BTBuckets) to display different content to visitors based on actions they take on my site. The javascript is working fine, but I noticed that if I simulate BTBuckets being disabled using Firefox Adblock none of the content shows up. So in the off chance of the service going offline it'll leave some pretty funky holes in the my content. I tried <noscript> tags which works with javascript off, but the content is still blank when I disable BTBuckets. I'm wondering if there's a way to display the default content if the service is unavailable? Here's the code I'm using: In the head: Code: <script type="text/javascript"> //<![CDATA[[ $BTB={s:XXXXX}; $BTB.jsh="http://static.btbuckets.com/bt.js"; //]]> </script> <script type="text/javascript"> document.write(unescape("%3Cscript src='" + $BTB.jsh.replace(/(https?:)/i,document.location.protocol) + "' type='text/javascript'%3E%3C/script%3E")); </script> The code in the body used to replace an image depending on visitor behavior: Code: <script type="text/javascript"> var _t = ""; if ($BTB.clusters["ppc_visitors"]) { _t = "\"images/top-photo-tracking-number.jpg\" alt=\"Call Toll-Free: 1-800-XXX-XXXX\">"; } else { _t = "\"images/top-photo.jpg\" alt=\"Call Toll-Free: 1-800-XXX-XXXX\">"; } document.write('<img src= ' + _t ); </script> <noscript><img src="images/top-photo.jpg" alt="Call Toll-Free: 1-800-XXX-XXXX"></noscript> Hi, I am hoping I just need to be pointed in the right direction with this. I have Page1. When Page1 body onloads it uses Ajax to call PartA Within PartA I have a message board so members can write messages which will be sent to my database in PartA[1] and immediately posted for view on to PartA[2]. As I want to have my request to the server updating regularly I want to have PartA[2] on a timed loop to refresh - I do not need the content of PartA[1] to refresh. So the order of events would look like this: Page1 | onload call | v PartA / \ V V PartA[1] PartA[2] (loads once) (constantly refreshes) What I am not sure about is that I have <body> and <head> attributes in Page1 only. I have already used my body onload to call PartA (and can't use it to call PartA[2] before PartA has loaded anyway). I do not want the user to have to click a button or do anything to call up PartA[2]. So my question is how would I get PartA[2] to automatically load within PartA? I hope I have made this clear, but if I haven't let me know and I will try again. I need some help with some javascript I am trying to put on an IF forum. http://s7.invisionfree.com/AJAXTEST/index.php At the very top, you will see a link called "on this link". It is an ajax code. If you click on it, a blank alert box comes up. However, if you go he http://commx.info/will/test.html and click on the same link, the alert box has the text I am looking for. It uses the exact same code, so I can't figure out why it works on a plain page and not on an IF forum. Does anyone have any ideas? The code is Code: <html><head> <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"><script> function callback(serverData, serverStatus) { alert(serverData); } function ajaxRequest() { var AJAX = null; if (window.XMLHttpRequest) { AJAX=new XMLHttpRequest(); } else { AJAX=new ActiveXObject("Microsoft.XMLHTTP"); } if (AJAX==null) { alert("Your browser doesn't support AJAX."); return false } AJAX.onreadystatechange = function() { if (AJAX.readyState==4 || AJAX.readyState=="complete") { callback(AJAX.responseText, AJAX.status); } } AJAX.open("GET",'http://commx.info/accounts/codes/shout/ipb13/getChatData.php?lastID=0', true); AJAX.send(null); } </script> </head><body><a href="javascript:ajaxRequest()">on this link</a></body></html> Hello everyone. I was working on a ajax function and I can't seem to figure out what I'm doing wrong here. I'm kinda new with the prototype method I was wondering if I could get some help figuring out what I'm doing wrong here exactly and how I can fix this. Any help on this would be wonderful. Thanks, Jon W Code: function createAjax() { if(!this.http && window.ActiveXObject) { try { this.http = new ActiveXObject("Msxml2.XMLHTTP" || "Microsoft.XMLHTTP"); } catch(e1) { this.http = false; } } if(!this.http && window.XMLHttpRequest) { try { this.http = new XMLHttpRequest(); } catch(e2) { alert("Sorry we was unable to make a request between your browser."); } } } createAjax.prototype.request = function(url) { var rmd = Math.random(); this.http.open('get', url+"&rmd="+rmd, true); this.http.send(null); this.http.onreadystatechange = this.responseHandler; } createAjax.prototype.responseHandler = function(obj) { if(this.http.readyState == 4) { document.getElementById(obj).innerHTML = this.responseText; } } function ajax(url, obj) { a = new createAjax(); a.request(url); a.responseHandler(obj); } var doAjax = new ajax('ajax.php?name=jon','content'); |