Please indicate the source if you need to repost.

Client jQuery could initialize a cross-domain request. Certainly, jQuery could initialize a NetSuite request.

jQuery code (client):

        function clickMe() {
try {
var myUrl = your_http_url;
$.ajax({
url: myUrl,
dataType: 'jsonp',
data: { "myName1": 2345 },
jsonp: 'callback',
jsonpCallback: "asyncButton",
success: function (result) {
for (var i in result) {
alert(i + " : " + result[i]); //Print response result
}
},
error: function (result1) { alert(2) },
timeout: 3000
});
}
catch (ex) {
alert(ex);
}
}

Client jQuery

Suitelet code (server):

function asyncButton(request, response) {
var x = request.getParameter('myName1');
var y = request.getParameter('myName2');
nlapiLogExecution('debug','test',x+', '+y);
response.write('asyncButton({"myName":"DanielCai"})');
}

NetSuite Suietlet

Note: Suitelet MUST check the 'Available without login' option.

Howerver, this kind of request doesn't have any credentials, which means it's an insecure request.

Restlet seems an optiop. I tried with Restlet, it didn't work out.

I guess the reason why it failed:

Cross-domain request MUST set 'Access-Control-Allow-Origin' in the server headers.

And Restlet doesn't allow coder to set the headers, so doesn't Suitelet.

I think the 'Available without login' option set the headers for us. :)

That's why Suitelet works for client jQuery

// Allow all the other parties to access.
header('Access-Control-Allow-Origin:*');
// Response type
header('Access-Control-Allow-Methods:POST');
// Response headers
header('Access-Control-Allow-Headers:x-requested-with,content-type');

PHP Server

Client JQuery invoke NetSuite Suitelet的更多相关文章

  1. .NET invoke NetSuite Restlet

    Please indicate the source if you need to repost. Restlet allows programmers to use the http request ...

  2. 手机新闻网站,手持移动新闻,手机报client,jQuery Mobile手机新闻网站,手机新闻网站demo,新闻阅读器开发

    我们坐在地铁.经常拿出新浪手机查看新闻.腾讯新闻,或者看新闻,等刷微信功能.你有没有想过如何实现这些目标. 移动互联网.更活泼. 由于HTML5未来,jQuery Moblie未来. 今天我用jqm的 ...

  3. 手机新闻网站,掌上移动新闻,手机报client,jQuery Mobile手机新闻网站,手机新闻网站demo,新闻阅读器开发

    我们坐在地铁,经常来查看新浪手机新闻,腾讯新闻.或者刷微信看新闻更多功能.你有没有想过如何实现这些目标.移动互联网,更活泼. 因为HTML5到,jQuery Moblie到.今天我用jqm为了给你一个 ...

  4. JQuery invoke remote webservice

    Sending the Access-Control-Allow-Origin header allows basic cross-origin access, but calling ASP.NET ...

  5. Writing Your Own jQuery Plugins

    Setting Up <script src="js/jquery-1.9.1.min.js"></script> <script src=" ...

  6. org.codehaus.xfire.XFireRuntimeException: Could not invoke service.. Server returned error code = 404 for URI.. Check server logs for details

    严重: Servlet.service() for servlet jsp threw exceptionorg.codehaus.xfire.XFireRuntimeException: Could ...

  7. Learning WCF Chapter1 Generating a Service and Client Proxy

    In the previous lab,you created a service and client from scratch without leveraging the tools avail ...

  8. 【ASP.NET Web API教程】1.1 第一个ASP.NET Web API

    Your First ASP.NET Web API (C#)第一个ASP.NET Web API(C#) By Mike Wasson|January 21, 2012作者:Mike Wasson ...

  9. MSCRM 通过Ajax调用WCF服务

    Call WCF Service from Dynamics CRM using AJAX A couple of days back, I had one of my ex-colleagues c ...

随机推荐

  1. Struts2整合Hibernate3实现用户登录功能

    所用技术:struts2 ,hibernate,jsp,mysql 本DEMO仅仅实现用户登录功能,采用MVC思想,自己也觉得相对是比较简单,比较容易理解数据流向的一个例子,通过整合这个过程,能够清晰 ...

  2. [java] 汇率换算器实现-插曲1-正则表达式(1)

    [java] 汇率换算器实现-插曲1-正则表达式(1) // */ // ]]> // */ // ]]>   [java] 汇率换算器实现-插曲1-正则表达式(1) Table of C ...

  3. java中map插入相同的key

    测试用例: package test; import org.junit.Test; import po.Person; import java.util.HashMap; import java.u ...

  4. nodejs学习笔记三——nodejs使用富文本插件ueditor

    在做自己的nodejs项目的时候遇到需要使用ueditor.原来下载的是ueditor的jsp版本.目录如下  在ueditor.config.js中有配置服务器home路径(这个home路径能找到u ...

  5. 我如何调优SQL Server查询

    我是个懒人,我只想干尽可能少的活.当我干活的时候我不想太多.是,你没看错,这看起来很糟糕,作为一个DBA这很不合格.但在今天的文章里,我想给你展示下,当你想对特定查询创建索引设计时,你如何把你的工作和 ...

  6. 抓取代理IP

    写脚本从指定网站抓取数据的时候,免不了会被网站屏蔽IP.所以呢,就需要有一些IP代理.随便在网上找了一个提供免费IP的网站西刺做IP抓取.本次实践抓取的是其提供的国内匿名代理.可以打开网站查看一下源码 ...

  7. The conversion of a varchar data type to a datetime data type resulted in an out-of-range value

    刚刚有在程序中,传递一个空值至MS SQL Server数据库,这个值的数据类型为DATETIME执行时,它却发生了如标题提示的异常:The conversion of a varchar data ...

  8. 硬链接 and 软链接

    硬链接 软链接

  9. C#操作word或excel及水晶报表,检索 COM 类工厂中 CLSID 为 {} 的组件时失败,原因是出现以下错误: 80070005

    解决办法一:<转自http://www.cnblogs.com/Sue_/articles/2123372.html> 具体解决方法如下: 1:在服务器上安装office的Excel软件. ...

  10. 不可或缺 Windows Native (17) - C++: 类与对象

    [源码下载] 不可或缺 Windows Native (17) - C++: 类与对象 作者:webabcd 介绍不可或缺 Windows Native 之 C++ 类与对象 示例1.类的设计CppE ...