Miva Merchant Community Forums

Page 6 of 6 FirstFirst ... 4 5 6
  1. #51
    Join Date
    Aug 2010
    Location
    East Dundee, IL
    Posts
    109

    Default Re: Any simple examples of ajax use in module?

    If you're using a regular XmlHttpRequest (looks like you are), then you're going to be fine. JavaScript and browsers have something called the "Same-Origin Policy", which means, any request to a site which isn't of the same origin is stopped immediately. The only way around this is to use JSON-P, or to use CORS (Cross-Origin Resource Sharing). CORS works by sending specific headers to the server you're trying to talk to, and then the server will typically look over the request, see if the domain is on their whitelist of "Okay" domains, and then give a response.

    JSON-P, is actually calling a third party website, but not with an XmlHttpRequest. It's looking at it with the src attribute of the SCRIPT HTML tag. So it's different in the way that it connects to the site (from what I know, I could be wrong though).

    If the site that you're working from is dev.myprogram.com you're fine, as the domain is the same.

    It doesn't matter what server/engine is processing the request (Apache, nginX, G-WAN, Cherokee, empressa, etc), as it is concerned about the domain it's connecting to, not the service which is handling the connection.

    Think of it like a mail man delivering a piece of mail. He needs to have the right address, that's all that matters. If the letter is written in french, it's up to the people at the address to get it to the right person.

    With servers, you have different "listeners", which "listen" on different ports. When you have an IP address and a port, you have what is called a socket. The Same-Origin Policy is dependent upon the same socket. So you can't have an Ajax request going to www.example.com:8080/cool_response.php, being requested from www.example.com/ajax_demo.php.

    The default http port is 80. So, for the sake of simplicity, browsers don't put that up there, since it's assumed.

    What that means is that Apache, or the engine/service which is handling the HTTP connections, is listening to port 80.

    The reason I'm going into all of this, is because of the way that Empressa is configured. If you look at your .htaccess file, you'll see something in there called a "handler" and a "type".

    AddType application/x-miva-compiled .mvc
    Action application/x-miva-compiled /cgi-bin/mivavm

    That's saying to apache, "Hey, we're going to handle these specific files in this specific way." So all requests to a .mvc file (even URL rewritten requests, with the file extensions removed) will be handled by the virtual machine (/cgi-bin/mivavm) on the server. This allows empressa and apache walk hand-in-hand into the sunset.

    The handling of the .php files will probably be in the httpd.conf file or possibly in the .htaccess. Most likely though, it'll be in the httpd.conf file, since it's usually a universal solution, and shouldn't have to be checked at every connection.

    SO, if there was an issue wondering about how .php files and .mvc files can work together, it's a non-issue, since apache is working like a "reverse proxy", passing off the .mvc requests to empressa, and getting the results from there. They listen to the same port, and can therefore sit on the same domain and socket.

    And, Miva Merchant deserves a very big "Thank you!!" for that, since it makes our lives (and theirs) much easier.

    Also, in case anyone gets adventurous and wants to work with XMPP (Jabber protocol, or a fancy way of instant messaging), you'll find yourself having to do some workaround in order to get everything up to snuff. I think a lot of the typical solutions will result in iframes, as those will give you some more flexibility.
    PCINET, LLC

    Miva Merchant Design, Development, Integration & Support
    We built the most Miva Merchant stores!
    Miva shopping cart design & integration service and our Portfolio!

    e-mail: tim.bolton@pcinet-llc.com
    web: www.pcinet.com

    "We who cut mere stones must always be envisioning cathedrals."
    Quarry Worker's Creed

  2. #52
    Join Date
    Dec 2009
    Posts
    1,331

    Default Re: Any simple examples of ajax use in module?

    titus: Thanks for the reply. Glad to have additional information about AJAX as it is all new to me in the past couple of months.
    Glad to know that I'm not yet in the position of knowing just enough to be dangerous :)
    Larry
    Last edited by wajake41; 03-15-13 at 03:58 PM.

  3. #53
    Join Date
    Dec 2009
    Posts
    1,331

    Default Re: Any simple examples of ajax use in module?

    Titus: When you say: "JavaScript and browsers have something called the "Same-Origin Policy", which means, any request to a site which isn't of the same origin is stopped immediately." Does this mean that another site attempting to use my PHP program via AJAX will be blocked by the server?
    Larry

  4. #54
    Join Date
    Aug 2010
    Location
    East Dundee, IL
    Posts
    109

    Default Re: Any simple examples of ajax use in module?

    They'll actually be blocked by the browser.

    But yes, that's accurate.
    PCINET, LLC

    Miva Merchant Design, Development, Integration & Support
    We built the most Miva Merchant stores!
    Miva shopping cart design & integration service and our Portfolio!

    e-mail: tim.bolton@pcinet-llc.com
    web: www.pcinet.com

    "We who cut mere stones must always be envisioning cathedrals."
    Quarry Worker's Creed

  5. #55
    Join Date
    Dec 2009
    Posts
    1,331

    Default Re: Any simple examples of ajax use in module?

    Thanks for the clarification.
    Larry

  6. #56
    Join Date
    Mar 2006
    Location
    France
    Posts
    214

    Default Re: Any simple examples of ajax use in module?

    Quick question (just curiosity). Why no one is using jQuery (or other framework) ? Is there a limitation inside Miva Merchant?

    Thank you
    Emma
    Miva Script - www.mivascript.org - only for MivaScript developers (new website in construction)
    Zen Radio : Relax yourself: www.zenradio.fm

  7. #57
    Join Date
    Aug 2010
    Location
    East Dundee, IL
    Posts
    109

    Default Re: Any simple examples of ajax use in module?

    Quote Originally Posted by Emma View Post
    Quick question (just curiosity). Why no one is using jQuery (or other framework) ? Is there a limitation inside Miva Merchant?

    Thank you
    Emma
    There's no limitation with jQuery. I think it was an initial barebones question without a library. There are a few places in the thread where it talks about jQuery, and I posted an AJAX queue inside here.

    I use jQuery, since it's ubiquitous. But if I'm on a site where I just need a simple method for calling the server, then I won't pull in a whole library to do the job of one function.
    PCINET, LLC

    Miva Merchant Design, Development, Integration & Support
    We built the most Miva Merchant stores!
    Miva shopping cart design & integration service and our Portfolio!

    e-mail: tim.bolton@pcinet-llc.com
    web: www.pcinet.com

    "We who cut mere stones must always be envisioning cathedrals."
    Quarry Worker's Creed

  8. #58
    Join Date
    Mar 2006
    Posts
    1,682

    Default Re: Any simple examples of ajax use in module?

    I've used jQuery for some other projects; it's a great tool. I may end up using it for this job as well, as it grows in complexity. I did look at the documentation on the jQuery ajax() function, and it didn't look any easier than the straight JS for this task.
    Last edited by Kent Multer; 03-18-13 at 12:34 PM.
    Kent Multer
    Magic Metal Productions
    http://TheMagicM.com
    * Web developer/designer
    * E-commerce and Miva
    * Author, The Official Miva Web Scripting Book -- available on-line:
    http://www.amazon.com/exec/obidos/IS...icmetalproducA

Posting Rules

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •