Solved

ajax issue

Posted on 2013-12-12
9
324 Views
Last Modified: 2013-12-13
I have a html doc that allows you to click the game you want which directs you to a frames aspx page. The latest component I'm having a issue with. You can load a xml file statically and that works great and everything is wonderful. Cause this control kicks ass but if you

try this
function getData() {
      var xmlPath = 'xml/nhl/scores/real';
var xmlGameID = QueryString.gameID;
      $.ajax({ url: xmlPath +"/"+xmlGameID+".xml"}).done(processGame);
}

You get nothing I noticed in Fire Bug switching from two sports NBA and NHL WELL THEY BOTH WORK IN SIMILAR FASHION. Broken NHL HAS  red text dev.sportsnetwork.com/aspdata/nhl2/xml/nhl/scores/real/18011.xml

the aspdata/nhl2 gets added.

while basketball has a black text dev.sportsnetwork.com/xml/nhl/scores/real/18011.xml

so I tried

function getData() {
	 var xmlPath = '/xml/nhl/scores/real';
                var xmlGameID = QueryString.gameID;
	 
	 $.ajaxSetup({ cache: false });
                $.ajax({
                    type: "GET",
                    url: xmlPath +"/"+xmlGameID+".xml",
                    dataType: "xml",
					 success: function(data){
                         var d = $(data);
						 processGame();
      if (d.find('Play').attr("Status").toUpperCase() === "FINAL") {
        clearInterval(myVar);
	  }
					 }
	  });
	 
	  }
	  

Open in new window

 and A few more to realize you as in me need help. I'm sorry if it's hard to explain
But it's passing game Id in browser line then page grabbing it and load xml information.

EE HELP THIS IF WORKING IS A KICK ASS CONTROL. CHRIS
Dropdown2.html
players.js
0
Comment
Question by:powerztom
  • 5
  • 4
9 Comments
 
LVL 42

Assisted Solution

by:Chris Stanyon
Chris Stanyon earned 500 total points
Comment Utility
Hey Tom,

It's because of a leading forward slash in your path name - without it, your script will look in the current folder. With it, it will look to the root of your website.

If you set you path to this:

var xmlPath = '/xml/nhl/scores/real';

Then it will add that to your domain name and look here:

yourDomain.com/xml/nhl/scores/real

If you set it like this:

var xmlPath = 'xml/nhl/scores/real';

then it will add it to the folder you are currently in, so if your page is in a folder called aspdata/nhl2 then it will look in :

yourDomain.com/aspdata/nhl2/xml/nhl/scores/real
0
 
LVL 42

Accepted Solution

by:
Chris Stanyon earned 500 total points
Comment Utility
FYI - That code is never going to work properly, even if it finds the correct XML data file. The processGame() function expects a parameter - it needs the game data passing to it, so you should call it like this:

processGame(data);
0
 

Author Closing Comment

by:powerztom
Comment Utility
Thanks again my friend the only thing I realized is that IFRAMES don't work with dropdowns so if you drop down your selection is ignored. Unless you know of some magic. Thanks Chris for explaining the differences with the slashes and also adding the parameter data after ProcessGame I love this site you learn from all stars I keep saying I'm the only programmer at my job and I really did desktop engineering VB6 VB.NET and now I have no colleagues to ask questions. My friends aren't into computers So the site and guys like you are saviors. I wish I was in England and drinking yards with you. Have a Great Weekend.
0
 
LVL 42

Expert Comment

by:Chris Stanyon
Comment Utility
No worries Tom,

Pleased it's working. The dropdown should work in iFrames as the content of an iFrame is just an HTML page - without seeing how you've implemented it I can't really help you out. If you want me to take a look, post a link to your page...
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:powerztom
Comment Utility
OK Chris I put hockey in the public area

http://sportsnetwork.com/gamecast/nhl2/dailynhl.html


in case you have problems
http://sportsnetwork.com/gamecast/nhl2/NhlIframe.aspx?gameID=18063

It's a rough version it will look better after graphics department handles this.



Rob what about having one button and it's job is two process both dropdown values? That wouldn't be soo bad would it ?
0
 
LVL 42

Expert Comment

by:Chris Stanyon
Comment Utility
Can't connect to the nhliframe page!!
0
 

Author Comment

by:powerztom
Comment Utility
MY boss is Rob there's a Rob on EE sorry calling you Rob. I gotta proof read. The sports network site has http://www.sportsnetwork.com/merge/tsnform.aspx? any aspx pages have to have this PRETEXT before it. I didn't know it yesterday I thought I found a way around for the outside world to avoid using that pretext to view a aspx page but you proved me wrong only html pages can be viewed


but this is the aspx page probably won't help but with a guy like you you never know

<%@ Page language="vb" EnableSessionState="false" %>


<!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" >
<head runat="server">
    <title>The Sports Network 2014 NHL Gamecast</title>
</head>
<script language="VB" runat="server" >
    Dim MYID As String = "OK"


Sub Page_Load(Source As Object, E As EventArgs)
       
   

   

        MYID = Request.QueryString("gameID")
        
End Sub
</script>
<body bgcolor="#000000">
    <form id="form1" runat="server">
    <div>
    <body>
<table width="784" border="0" class="tableborder">
  <tr>
    <td width="685"><iframe width='780x' height='225' scrolling='no' frameborder='no' src='http://dev.sportsnetwork.com/aspdata/NHL2/ScoreBoard4.html?gameID=<%= MYID %>'></iframe></td>
  </tr>
</table>
<table width="783" border="0">
  <tr>
    <td width="400"><p class="topmid"><iframe width='390
          ' height='520'
          scrolling='no' frameborder='no' src='http://dev.sportsnetwork.com/aspdata/NHL2/Roster.html?gameID=<%= MYID %>'></iframe>
      <iframe width='400
          ' height='300' scrolling='no' frameborder='no' src='http://dev.sportsnetwork.com/aspdata/NHL2/GOALIES.html?gameID=<%= MYID %>'></iframe>
    </p></td>
    <td width="383" class="topmid"><p>
    <iframe width='400
          ' height='315' scrolling='no' frameborder='no' src='http://dev.sportsnetwork.com/aspdata/NHL2/RinkV.html?gameID=<%= MYID %>'></iframe>
   </p>
   <iframe width='425
          ' height='500' scrolling='no' frameborder='no' src='http://dev.sportsnetwork.com/aspdata/NHL2/dropdown2.html?gameID=<%= MYID %>'></iframe>
   </td>
  </tr>
</table>
    </div>
    </form>
</body>
</html>

Open in new window

0
 

Author Comment

by:powerztom
Comment Utility
And the links are all to the development server. I created a image and using it as a button an first I put it  like this btngo is image button I thought it's go  practice to put button clicks inside doc ready function. Now I know that that will not work

$(document).ready(function() {
      
      getData();
      $('#filterPeriod, #filterAction').change(applyFilter);
      $('#btngo').click(function(){
      applyFilter();
     
   });
});

Now I know that that will not work cause I put this inside and outside of doc load function

$('#btngo').click(function(){
       alert("message");
     
   });
Just a simple message box so what's up and appyfilter is that the function that will take both values from the two dropdowns.

Chris I'm using IFrames to keep from having huge chunk of code do you think that is wise or have everything on the page which would be alot to troubleshoot. What's your opinion?
0
 

Author Comment

by:powerztom
Comment Utility
Chris,

I tried to use your code for a QB Ranking xml file with a scroll. I'm sure it something simple cause I followed every detail.
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28317959.html
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now