Jump to content

Ingolme

Moderator
  • Posts

    14,901
  • Joined

  • Last visited

  • Days Won

    177

Everything posted by Ingolme

  1. Ingolme

    AJAX

    It doesn't have to be, the only thing that really matters is the actual content being sent. As long as the response is valid JSON you can parse it on the client side with JSON.parse();
  2. Ingolme

    AJAX

    I just gave an example without key/value pairs because at my job I often am having to send requests to web services that don't use them. If you're writing both ends of the application, it certainly would be simpler in PHP to send the data in query string variables. You don't need to use the reviver parameter in JSON.parse(), it's just there for if you want to transform values that are read from JSON. MDN had a good explanation and examples about it.
  3. Ingolme

    AJAX

    To create the object, just create an XmlHttpRequest object: var xmlhttp = new XmlHttpRequest(); Here's an example of how to do a POST request: http://www.w3schools.com/ajax/tryit.asp?filename=tryajax_post2 You have to set the Content-Type header for POST data to work. If the page you're sending data to is a webservice that requires JSON input, just send a JSON string instead of a normal query string. You can convert a Javascript data structure using JSON.stringify(). If the response comes back in JSON format, use JSON.parse() to turn it into a Javascript object. To put it all together into one example: // The data to be sent var data = { item1 : "Item 1", item2 : "Item 2" }; // Create the request var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = handleResponse; xhttp.open("POST", "json.php", true); xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xhttp.send(JSON.stringify(data)); // The function that handles the response function handleResponse() { if (xhttp.readyState == 4 && xhttp.status == 200) { var response = JSON.parse(xhttp.responseText); console.log(response); } }
  4. This is not something HTML and Javascript can do. You need a server-side programming language like PHP to pull data from other websites.
  5. Ingolme

    AJAX

    jQuery 1.x.x supports old versions of Internet Explorer. jQuery 2.x and above don't. Is there any particular reason you want to support Internet Explorer 6? Internet Explorer 7 and above support the XmlHttpRequest object.
  6. What code have you set up so far? You need to send a request to their API, then parse the response. If their API does not support cross-site requests it won't work with just pure Javascript and you'll have to rely on PHP.
  7. That's not Firefox's problem, that's PHP's problem. Firefox has no idea what errors are going on at the server-side. You'll get a warning if you try to use the date() function without specifying a time zone first.
  8. In most RSS feeds, the HTML inside the description is escaped and not part of the DOM structure, it's just a string. You need to pull out that string and parse it separately. When it is part of the DOM it's in a different namespace, so you need to use getElementsByTagNameNS and specify the namespace.
  9. You can set the bottom border of the menu elements. The exact CSS code depends on your HTML structure.
  10. You might want to look into OpenGraph meta tags.
  11. Copyright is free and is automatically granted upon completion of a published work. Fighting for your copyright in court is a bit more complicated of a procedure.
  12. Ingolme

    qqq

    Is there a question here?
  13. Ingolme

    illegal Offset

    You don't need to create a protect() function, all you're really doing is wrapping mysqli_real_escape_string() inside another function. Any place where you intended to call protect(). just call mysqli_real_escape_string() instead.
  14. You can use multiple selectors by separating them with a comma: #block-block-55 h2, #block-block-56 h2, #block-block-57 h2 { text-align:center; }
  15. Ingolme

    illegal Offset

    I think this is very inefficient. You're opening a new connection to the MySQL database for every variable you want to escape. If you use prepared statements you won't need to do any kind of escaping and your code will be much more secure. You shouldn't use strip_tags before storing the data either, if you want to prevent people from injecting HTML onto the page, do the escaping after you've pulled the data out of the database. By manipulating the data before storing it you're losing information.
  16. Ingolme

    illegal Offset

    That means $_POST[$string] does not exist. You should check to see if it exists first.
  17. I don't believe the concept of an array exists in XSLT. There are just node lists.
  18. What programming language are you using?
  19. The ID is unique within the page. If, for any reason, you don't want to select an element that's not an <ht> you can use h1#chapter1. Usually you won't need to, but the example is there to show it's allowed. IDs may be unique within a page, but one same stylesheet can apply to many different pages. Perhaps on some of the pages #chapter1 is not an <h1> element.
  20. JavaScript was the scripting language invented for the Netscape browser. When the W3C created a formal specification for the language to be used across all browsers they named it ECMAScript.
  21. That will work. You should know that Javascript and PHP work very differently from eachother and run in their own environments. Javascript is not aware that PHP exists, PHP is not aware that Javascript exists. PHP is executed first, whatever is printed out by PHP will be read by the browser, the browser has no idea that PHP generated the content that is being viewed. View the source code of your page after it has loaded (Control+U in Firefox on Windows) to see what code the browser is seeing.
  22. The <body> element does not fill the whole viewport, if you set a background color to the body and put a single line of text in it you'll see that the body tag only extends as far down the page as the text does. The <html> element generally should fill the viewport, but I wouldn't rely on it. Setting height to a percentage value only works if the parent element also has a defined height, this is why the height needs to be applied to both the <html> and <body> tags.
  23. By that logic, neither are serif, sans-serif or monospace. You can't be sure any two browsers will render the exact same font when using generic types, but as far as supporting it, every browser supports it, they just render it in their own way. On my computer the cursive font is represented with Comic Sans. There's no font called "cursive" as far as I know, that's just a generic name. The same way there are no font files for "sans-serif", they aren't font names, they're just generic font types.
  24. The thing is that they're not words, they're variable names. When you put show there, what you're doing is telling it to use the value of a variable named show. Since there's no part of the code that says var show = "something"; it has no value and is undefined. If you want to pass a word into a function you have to wrap it in quotation marks: "show"
  25. I just linked to the W3C specification. Do you disagree with the W3C?
×
×
  • Create New...