weixin_33671935 2015-12-05 12:12 采纳率: 0%
浏览 4

Volusion API的问题

I am creating a website using volusion store. I want the products to displayed on products page and for that I am customizing the code. I have created the volusion api i.e, standard exports and I just need to fetch that products details to page using that api with ajax. so how do I achieve that? For the first type I have created api with .xml extension e.g, https:///dataport/dl/Generic/Products.xml then it shows the data and I can also fetch that data but for the second type of url e.g, http:///net/WebService.aspx?Login=&EncryptedPassword=&EDI_Name=Generic\Products&SELECT_Columns=p.ProductID,p.ProductName,pe.Photo_AltText,pe.Photo_SubText,pe.PhotoURL_Large,pe.PhotoURL_Small,pe.Price_SubText,pe.Price_SubText_Short,pe.ProductPrice,pe.ProductPrice_Name I can't able to fetch that data using ajax. Although using this url for the first time it shows data but when I refresh it then it doesn't show.

Below I have shared my code so please review it and help me to solve this issue,

<script>
    $(document).ready(function(){

$.ajax({
    type: "POST",
    url: "http://<domainname.com>/net/WebService.aspx?Login=<username>&EncryptedPassword=<password>&EDI_Name=Generic\Products&SELECT_Columns=p.ProductID,p.ProductName,pe.Photo_AltText,pe.Photo_SubText,pe.PhotoURL_Large,pe.PhotoURL_Small,pe.Price_SubText,pe.Price_SubText_Short,pe.ProductPrice,pe.ProductPrice_Name",
    dataType: "xml",
    success: function(result) {
        alert(result);
        parseXml(data);
    }
});

});
function parseXml(data) {
    var id;
    var code;
    var name; 
    $(data).find('Products').each(function( ){ 
        $(this).find("ProductCode").each(function() {
            code = $(this).text();
        });
        $(this).find("ProductID").each(function(){
            id = $(this).text();
        });
        $(this).find("ProductName").each(function(){
            name = $(this).text();
        });
        $('.col-md-6').append(code +"<br />"+ id +"<br />"+ name);
    });
}

</script>
<div id='getresult'>
    Api code will refelect here
    <div class="container">
        <div class="row">
            <div class="col-md-6"></div>
        </div>
    </div>
</div>
  • 写回答

1条回答 默认 最新

  • weixin_33676492 2015-12-06 17:16
    关注

    Absolutely Do Not Use This Method. Security Risk. Proceed to Second Section, Jquery Answer Deleted.

    How to do the java data call with jquery

    I've not had much luck using jquery to do it. But you might want to try something like this to do the jquery load you're attempting... you might want to check what version of jquery you're loading also as volusion gives you an old version for some reason. Add this to your template.html that you're using currently. you might need to upload it into your server with the other javascripts using ftp...

    <head>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    </head>
    

    On the page you want to access the data try this. (no promises but you need to double check your code syntax it seemed pretty off to me, you also have to have a where clause in your query if you're not using a custom asp page.)

    Script Removed As It Is Exploitable, and I refuse to promote unsafe practices in commerce.


    Securely Accessing the Volusion API Webservice With Custom Queries and Connections using a custom asp page.

    Use a Custom ASP Page for your own service Volusion does not support asp.net for custom scripts but you can use asp classic. You can make an asp page through the following method.

    1. Using XML read the querystrings, I suggest putting in code to sanitize it. For Example:

    dim oXMLHttp
    dim Xml_Returned
    
    set oXMLHttp = Server.CreateObject("Msxml2.serverXmlHttp")
    oXMLHttp.open "POST", "http://YourUrl/net/WebService.aspx?
    Login=YourEmail@YourDomain.com&
    EncryptedPassword=YourPassword&
    API_Name=Generic\Orders&SELECT_Columns=o.OrderID,o.OrderStatus,od.TotalPrice&
    WHERE_Column=o.OrderStatus&WHERE_Value=New", False
    
    oXMLHttp.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
    oXMLHttp.setRequestHeader "Content-Action", "Volusion_API"
    oXMLHttp.send
    
    Xml_Returned = oXMLHttp.responseText
    

    For More Information See Volusion Developer Documentation Samples

    1. Construct your SQL Query off of your querystring..

    2. Define your query string as a variable, your api connection string as a constant, and input it through the url. you can do a post but it's faster to just do a get.

    3. Write a custom sql file and save it in your generic folder that matches the query you want to make. Or, use vb's File System Object to create it on the http request.

    4. Create a xml schema file and store that inside the Schema/Generic folder as well.

    5. Now you call this file by hitting it with an httpget in java, YOURURL.COM/v/vspfiles/schema/generic/YOURCUSTOMSCRIPT.ASP?CUSTOMWHEREVARIABLEORWHATEVERITIS=THISISYOURMODIFIERUNLESSTHEQUERYISSTATIC

    6. If you created the sql file using asp's fso, delete the file after the call is made.

    7. Return the data into the javascript requesting it.

    See The answer from "TheCodeWhisperer" Posted on May 7 at 14:37 for a Example Code Doing Just What I'm Saying Here.

    Now I know this is a bit brief, but each result is different and this is how i know to do it, it's just more versatile for me over using jquery.

    Here are some additional links for your reference. Let me know if you need more help.

    You should be able to use this method. The following links will help. If you don't get anywhere i'll help you as soon as I have some more time.


    REFERENCES:

    评论

报告相同问题?

悬赏问题

  • ¥30 matlab ode45 未发现警告,但是运行出错
  • ¥15 vscode platformio
  • ¥15 代写uni代码,app唤醒
  • ¥15 全志t113i启动qt应用程序提示internal error
  • ¥15 ensp可以看看嘛.
  • ¥80 51单片机C语言代码解决单片机为AT89C52是清翔单片机
  • ¥60 优博讯DT50高通安卓11系统刷完机自动进去fastboot模式
  • ¥15 minist数字识别
  • ¥15 在安装gym库的pygame时遇到问题,不知道如何解决
  • ¥20 uniapp中的webview 使用的是本地的vue页面,在模拟器上显示无法打开